Suggestions for how to tackle this renaming scheme

Started by victorengel, June 18, 2021, 11:32:14 AM

Previous topic - Next topic

victorengel

Two cards, one was for raw files, one for jpeg files. The one with raws had issues, and a recovery using Lexar recovery tool recovered the files with names like f# where # is a sequential number, apparently. The other card is fine. I'd like to use the jpeg files as a guide to how to rename the recovered raw files.

My first thought is to do something like this:
* Store current filename into an EXIF field in the jpeg files. Let's call this field NEWFIELD
* Rename all files according to Date/Time Original.
* Write a script that loops through all jpeg files.

For each file:
* Capture the filename without extension.
* Extract the EXIF field value written from the first step
* Rename filename.cr2 to NEWFIELD.cr2

Do you see a problem with this scheme? Do you know of a simple way to implement it?

StarGeek

Quote from: victorengel on June 18, 2021, 11:32:14 AM
My first thought is to do something like this:
* Store current filename into an EXIF field in the jpeg files. Let's call this field NEWFIELD

I'd suggest XMP:PreservedFileName, optionally XMP:Title and IPTC:ObjectName.  The latter two are the placement recommended by the IPTC Photo Metadata Standard but Lightroom ignores this recommendation in favor of the first tag.

Quote* Write a script that loops through all jpeg files.

Sidenote, looping exiftool in a script is Common Mistake #3.  It is slow and almost never required.

I would suggest this sequence
Copy filename without extension into tag, this assumes you're using at least exiftool ver 12.22 or higher
exiftool "-XMP:PreservedFileName<BaseName" /path/to/jpegs/

Rename all files using SubSecDateTimeOriginal, as that will be less likely to have duplicate names.  Test it out first with Testname, then change to Filename if it looks correct.  Note that you can do both directories in one command
exiftool "-TestName<${SubSecDateTimeOriginal;}.%e" /path/to/jpegs/  /path/to/cr2s/

Copy tag and rename.  Again, testing first then change if looks good
exiftool -TagsFromFile /path/to/jpegs/%f.jpg "-Testname<$XMP:PreservedFileName.%e" /path/to/cr2s/

Rename jpegs back to original
exiftool "-Filename<$XMP:PreservedFileName.%e" /path/to/jpegs/

Test the whole thing out first, but this should work.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

victorengel

Thanks. I'm glad I asked. I'll try this out when I next have time.

victorengel

I'm getting an error on the second command:

exiftool "-TestName<${SubSecDateTimeOriginal;}.%e" ./JPG/ ./CR2/
zsh: bad substitution

I am doing this from the parent directory of JPG and CR2 directories.

Phil Harvey

Use single quotes instead of double quotes (see my signature).

- 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 ($).

StarGeek

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

victorengel

I saw that but promptly forgot. Works like a charm, but I'll change the last step to delete the jpegs because they've already been archived, so they're just temporary.