Main Menu

file name change

Started by moviejimmy, February 21, 2017, 05:06:32 AM

Previous topic - Next topic

moviejimmy

I came across this:

http://www.exiftool.org/index.html#filename
exiftool "-FileName<CreateDate" -d "%Y%m%d_%H%M%S.%%e" DIR

using CreateDate to change the file name.

What if I wanted to use CreateDate, Make, CameraModelName for the file name?

Looks something like:

DCI00567.jpg to 20170221-135602-Sony-NEX-6N.jpg

Thank you very much!!!

Phil Harvey

This thread discusses exactly what you want to do.

I recommend the semicolon after Make and Model to remove illegal characters from the file name.

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

moviejimmy

Thanks Phil! Exactly what I needed.

I tried this:

exiftool -P -d '%Y-%m-%d %H.%M.%S' \
    '-filename<${DateTimeOriginal}_${Make;}.%e' \
    '-filename<${CreateDate}_${Make;}_${Model;}.%e' \
    '-filename<${DateTimeOriginal}_${Make;}_${Model;}.%e' \
    $@

Is it correct that if all tags are available a file will get renamed three times?

I need to run this on about 20,000+ files. Is there a way I can speed things up a bit? e.g. by using -if? so that if DateTimeOriginal, Make and Model are all available, only the last line will be executed and the file will only get renamed once?

Hayo Baan

No need to try to be smarter than ExifTool; the rename is only done once :)
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

As Hayo said.

The last valid assignment takes precedence.  (eg. if DateTimeOriginal, Make and Model exist, then the first two assignments are ignored.)

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