Import media and replace files

I’m using the CSVImport module from Omeka S in order to import pictures of paintings that are getting associated with a notice of the painting.

Sometime, we have a better picture of the painting and we want to replace the previous picture by the new one. Unfortunately, it seems that CSVImport module is not keeping the original name of the jpeg file and is renaming it using something like a unique hash. This allow to have more that one file associated with a notice where I would like the second one to replace the first one.

How could that be possible?

Depending on how many files you want to update at a time, this may be easier to do manually than with CSV Import.

If you have the item IDs (or another unique value) already in your spreadsheet, you can do this in a two-stage process. This will delete every media attached to the given items, not any one file in particular, so this may not work for you.

First, run a CSV Import where you “Update” the items. Supply only one mapped column: an empty column, mapped to Media source > URL.

When CSV Import updates the items, it will wipe any existing media (and replace it with nothing). This shouldn’t mess up any metadata, item sets, sites, etc., but test it with a few items first to be sure you have it right. Then you can wipe all media from the items you intend to update.

Then you can run CSV Import as usual by adding the new media to the existing items.

If you have items with more than one media (photos of the back, details, etc.), and you want to delete only one image in order to replace it, that’s probably a manual job. Keep in mind that media are assigned unique IDs, just like items, starting with 1, so the older the media, the lower the number. You can change the columns that appear on the Media browsing page to show IDs and then sort using them, if that helps you search out the files you wish to delete.