Author Topic: conditionally using "Raw File Name" to rename / re-date date-mangled files.  (Read 84 times)


  • Jr. Member
  • **
  • Posts: 15
I'm always amazed at what Exiftool can do. It is an amazing tool!

I see from

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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
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
« Last Edit: February 19, 2019, 08:17:05 AM by Phil Harvey »
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).