Can I (and if yes how?) add parenthesis to the %c auto increment?

Started by k.mooijman, January 04, 2024, 04:50:16 PM

Previous topic - Next topic

k.mooijman

I use
exiftool '-filename<${subsecdatetimeoriginal;DateFmt("%Y-%m-%d_%H-%M-%S_%f")}_${make#;s/\s/-/}_${model#;s/\s/-/}_%-.2c.%e' *.jpg
to achieve this

2019-07-25_12-00-01_.60_NIKON-CORPORATION_NIKON-D5300.jpg
2019-07-25_12-00-01_.60_NIKON-CORPORATION_NIKON-D5300_-00.jpg
2019-07-25_12-00-01_.60_NIKON-CORPORATION_NIKON-D5300_-01.jpg

but would like to get

2019-07-25_12-00-01_.60_NIKON-CORPORATION_NIKON-D5300.jpg
2019-07-25_12-00-01_.60_NIKON-CORPORATION_NIKON-D5300(00).jpg
2019-07-25_12-00-01_.60_NIKON-CORPORATION_NIKON-D5300(01).jpg

Is this possible and if 'yes' how?

 


Phil Harvey

This may be done with a second command after setting them to -00.jpg etc:

exiftool "-filename<${filename;s/-(\d{2})\./($1)/ or $_=undef}" DIR

But try this out first on some test files to be sure it does what you want.

You will get warnings for files that aren't renamed.

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

k.mooijman

Thanks for the answer. But it is not the solution I was looking for.
I'm afraid that once again I'm trying something impossible.
It wouldn't be the first time  ::)

Phil Harvey

The alternative is to always add a copy number, then there isn't the problem because the brackets are always written.  Then afterwards you could remove the "(00)" if you wanted.  But of course the numbers would start with "(01)" then.

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