How to add a suffix on files without a matching pair

Started by thumperstrauss, January 21, 2024, 01:59:10 PM

Previous topic - Next topic

thumperstrauss

I have a folder of TIF files with file names like this:

photo001.tif
photo001_a.tif
photo002.tif
photo003.tif
photo003_a.tif

In some cases, the photo doesn't have a matching pair, that is, a version with the suffix _a at the end.

My goal is to move (1) all files with _a to another folder, and (2) any other files that don't have the _a. So, in the example above, I will move photo001_a.tif, photo002.tif, photo003_a.tif.

Can you recommend a script to achieve this, perhaps add the suffix _o to any photo that lacks a twin.

Background: I am scanning photos with the Epson FastFoto 680W scanner. The app creates two files: original and auto-corrected (which affixed _a at the end). In some cases, the auto-corrected version is not good and I delete it. However, I need to move all "final" tif files to a folder for eventual conversion to JPG, update of meta data date taken, and upload to Google Photos. So, searching all the files with _a.tif will miss the photos that I chose not to auto-enhance.

Phil Harvey

This is a bit tricky.  ExifTool generally deals with one file at a time, so doing stuff like this is difficult, but here goes...

I think you can do what you want with the following command:

exiftool -directory="NEW_DIR" -tagsfromfile %d%f_a.%e -directory -fileorder filename DIR

This should move all "_a" files, plus any file that didn't have a "_a" counterpart.  You will get an "Error opening" warning for every file that is moved, but that is by design.

The -fileOrder option is necessary to be sure the non-"_a" files are checked first.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).