Can the copy number be used to modify the first file name?

Started by Martin B., September 29, 2013, 06:24:59 PM

Previous topic - Next topic

Martin B.

Hi,

I use the following to rename my files by date:
exiftool -P "-FileName<CreateDate" -d "%Y-%m-%d_%H-%M-%S%%+c.%%e" -directory=Renamed .

If two or more pictures were taken during the same second, the resulting file names will be something like this:
2013-07-06_10-32-39.CR2
2013-07-06_10-32-39_1.CR2
2013-07-06_10-32-39_2.CR2
2013-07-06_10-32-39_3.CR2
etc.

Assuming the original files were named in the order they were taken, I have observed that exiftool will always name the oldest file without the "_1" suffix, and the following (more recent) files will be named with suffixes in increasing numerical order.

Is there a way, using only the exiftool application, to name the first file with the _1 suffix, the second with _2, and so on, but only if there are more than one file with the same name (i.e. taken during the same second). In other words, to have something in this format:
2013-07-06_10-31-15.CR2
2013-07-06_10-32-39_1.CR2
2013-07-06_10-32-39_2.CR2
2013-07-06_10-32-39_3.CR2
2013-07-06_10-36-04.CR2
etc.


I know about the ".n" modifier to the %c format, but the effect of this modifier is to add the "_1" suffix to all files, even those without "siblings in the same second".

Right now, I search and modify by hand these groups of siblings, and I'm about to write a Perl script to do it automatically, but I'm wondering if a solution might already exist.

Thanks for any help and suggestions,

Martin


Phil Harvey

Hi Martin,

Sorry, what you ask is not currently possible with ExifTool.  ExifTool does the renaming in a single pass, so it can't know ahead of time if the first file with a give name should have a copy number appended to it or not.

The order that ExifTool runs through the files is system dependent, and depends entirely on the order returned by the system when scanning the directory.  However, having just said that ExifTool is single-pass, the -fileOrder option may be used to specify the order in which ExifTool evaluates the files, and this option does invoke a second pass.

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