Hello,
I have the following command to rename a file to the date/time of it's DateTimeOriginal:
exiftool -d '%Y%m%d-%H%M%S%+.c.%%e' '-filename<DateTimeOriginal' .
This works great, but I want to actually have a plus sign in the filename, not an underscore, which is what the plus sign is replaced with. Is it possible to escape this somehow please?
This is easy since you always want the number in the name:
-d '%Y%m%d-%H%M%S+%.c.%%e'
The %-c and %+c are only useful if you don't want the number when there is only one file with that name.
- Phil
Sorry Phil, I think in my testing of different commands, I pasted the wrong one in my post.
Ideally, I'd like the first file it encounters to not have a modifier, but all subsequent ones to have +1, +2 etc.
The command I came up with so far is:
exiftool -d '%Y%m%d-%H%M%S%%+c.%%e' '-filename<DateTimeOriginal' .
However, this is the code that outputs a underscore instead of a +.
If I follow your suggestion on this and move the plus sign before the percentage, it leaves the first file with a plus sign then the extension, e.g. 20250205-180000+.jpg
There are only two options for the %c, either a minus sign (%-c) or an underscore (%+c).
You'll have to run the command with one of these first, then run a second command to change to a plus sign.
This should change an Underscore### into Plus###. Test it out first, as I have not done so.
exiftool -if "$BaseName=~/_\d+$$/" "-Filename<Basename;s/_(\d+)$/+$1/}.%e" /path/to/files/
Thanks both :)