'Is there any way to match image name from CSV with Image in Media Library?

I want to assign my media library images to product image when importing CSV.

CSV file has 10000 products and image column has google drive image URL i manage to get image name from google drive API. Now i got stuck in process function how i can get image names from media library already uploaded there and compare with my CSV image name if matched then that product will assigned that image.

function add_column_to_mapping_screen( $columns ) {
    $columns['Custom Img Url'] = 'custom_img_url';
    return $columns;
}
add_filter( 'woocommerce_csv_product_import_mapping_default_columns', 'add_column_to_mapping_screen' );

function process_import( $object, $data ) {
    
    if ( ! empty( $data['custom_img_url'] ) ) {
        $object->update_meta_data( 'custom_img_url', $data['custom_img_url'] );
    }

    return $object;
}
add_filter( 'woocommerce_product_import_pre_insert_product_object', 'process_import', 10, 2 );


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source