DateFmt option - how to use it

Started by Sunny, November 01, 2024, 05:22:20 AM

Previous topic - Next topic

Sunny

I would like to understand how the DateFmt option works. I have analysed the example, but I don't quite know how to apply it in real life.

exiftool -p '${createdate#;DateFmt("%Y-%m-%d_%H%M%S")}' a.jpg

Now I can rename a file and/or folder using these methods

BAT file
exiftool -k "-FileName<CreateDate" -d "%%Y.%%m.%%d\%%Y.%%m.%%d (%%H.%%M.%%S)%%%%+2nc.%%%%e" %1
and
exiftool -k "-FileName<${CreateDate}" -d "%%Y.%%m.%%d\%%Y.%%m.%%d (%%H.%%M.%%S)%%%%+2nc.%%%%e" %1

I wanted to try DateFmt method but it doesn't work for me, can you help me understand it?
exiftool -k "-FileName<${CreateDate;DateFmt("%%Y.%%m.%%d\%%Y.%%m.%%d (%%H.%%M.%%S)")}.%%%%+2nc" %1

Phil Harvey

This is a quoting issue.  Your inner quotes need to be different from your outer quotes. 

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

Sunny

Thanks Phil, indeed changing the inner duble quotation marks (") to single (') quotes solved the problem  :)

exiftool -k "-Directory<CreateDate" -d "%%Y.%%m.%%d" "-Filename<${CreateDate#;DateFmt('%%Y.%%m.%%d (%%H.%%M.%%S)')}.%%e" %1