conditionally using "Raw File Name" to rename / re-date date-mangled files.

Started by clem, February 19, 2019, 04:08:35 AM

Previous topic - Next topic

clem

I'm always amazed at what Exiftool can do. It is an amazing tool!


I see from

https://exiftool.org/forum/index.php?topic=5203.0

That I can use

exiftool "-filename<rawfilename" DIR

to rename files according to embedded "Raw File Name" tags.

How do I conditionally change a filename to the 'Raw File Name' that is embedded in it if the existing filename isn't the same as the 'Raw File Name' originally used?  Then to prevent the file from being mis-renamed again, changing the "Metadata Date" to that 'Raw File Name' as well?

thanks as always for tips, suggestions and pointers!




Phil Harvey

Maybe something like this?:

exiftool -ext jpg "-filename<${rawfilename;s/\.\w+$/.jpg/}" -if "$filename ne ${rawfilename;s/\.\w+$/.jpg/}" DIR

This assumes you use lower-case .jpg extensions.  You will have to copy over the MetadataDate in a separate command.

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