How to restore images for a Shopify product you’ve overwritten accidentally by CSV file

Problem: (wrong handling of CSV files)

Yesterday I wanted to bulk-edit products in Shopify, and to change the vendor. I used LibreOffice to select just the rows with the vendor in it, updated it, and uploaded only these updated rows as a new CSV to Shopify.

The result was that Shopify dropped many variants, and forgot all the images.

Even after re-uploading the corrected CSV with all rows back in place (for all variants), the images were still missing and were simply ignored by Shopify.

My learning from this: be careful around handling CSV files around Shopify, be sure to always include all rows for a product if you are updating an existing product.

But we still need a solution for the missing image files.

The solution:

I called Shopify support, and asked them to restore the images. They were able to do this – but to a somewhat different location!

The images then show up with a different link, so the CSV file has to be edited.

Due to the nature of this particular problem (where I only uploaded the first row), the first row does NOT need to be updated (as the image still exists in the proper location, and does NOT exist in the different location)

I have written a script which handles this update, and also fixes another bug which my german libreoffice introduced (it was saving “FALSCH” instead of “false” and “WAHR” instead of “true”).

Download the script here:

This is a Ruby script, compatible with Ruby v2.x. (I’ve developed and tested it on Windows). Run it to see a little help being displayed at the start.

I release it here without any warranty of any kind, in the hope that it will be useful. Double-check the output before uploading to Shopify.


For example:

This image path was in my CSV file:

https://cdn.shopify.com/s/files/1/1560/1473/products/PB4_Mock-02.jpg?v=1608641168

it needed to be replaced to this one:

https://cdn.shopify.com/s/files/1/1560/1473/files/products/PB4_Mock-02.jpg?v=1628264444

(what my script actually does is to just insert the additional /files/ string – the different version at the end seems to be OK)

In case you need help with the script / adjusting the image location, we are available for hire as consultants.

Finally I am deeply grateful to the Shopify support which was able to restore those images. Without them it would have been a lot of work locating them on my harddrive, reuploading them, etc.