ExifTool Forum

ExifTool => Newbies => Topic started by: Stephen Marsh on January 01, 2019, 09:29:01 PM

Title: Reset Sequential Numbering for Each Directory Processed?
Post by: Stephen Marsh on January 01, 2019, 09:29:01 PM
A similar thread here:

http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,9289.msg48005.html#msg48005

However I wish to reset the increment number on each folder processed…

Before:

DIR
   SubDir-A
      batch-A1.png
      batch-A2.png
      batch-A3.png
   SubDir-B
      batch-B1.png
      batch-B2.png
      batch-B3.png

After:

DIR
   SubDir-A
      batch-A1-001.png
      batch-A2-002.png
      batch-A3-003.png
   SubDir-B
      batch-B1-001.png
      batch-B2-002.png
      batch-B3-003.png

What I can currently do is the following, which is undesired:

DIR
   SubDir-A
      batch-A1-001.png
      batch-A2-002.png
      batch-A3-003.png
   SubDir-B
      batch-B1-004.png
      batch-B2-005.png
      batch-B3-006.png

exiftool '-filename=%f_%.3nC.%e' -r 'DIR'

Is this possible?
Title: Re: Reset Sequential Numbering for Each Directory Processed?
Post by: Phil Harvey on January 02, 2019, 07:46:12 AM
Currently there is no way to do this.

Adding this option would be easy except that I can't think of a good syntax to use for specifying this.  Doing %-C would make sense (because the "-" is somewhat redundant with %C), but this would break backward compatibility in the case where someone was already using %-C.

- Phil
Title: Re: Reset Sequential Numbering for Each Directory Processed?
Post by: Phil Harvey on January 02, 2019, 08:25:10 AM
I think I'll go ahead and change the meaning of '-' and '+' when used with %C.  Hopefully this won't affect too many people.  Here is the proposed update to the documentation:

            A special feature allows the copy number to be incremented for
            each processed file by using %C (upper case) instead of %c.  This
            allows a sequential number to be added to output file names, even
            if the names are different.  For %C, a copy number of zero is not
            omitted as it is with %c.  A leading '-' causes the number to be
            reset at the start of each new directory, and '+' has no effect.

            [...]

This will be implemented in ExifTool 11.24 unless I hear an objection.

- Phil
Title: Re: Reset Sequential Numbering for Each Directory Processed?
Post by: Stephen Marsh on January 03, 2019, 12:27:47 AM
Thanks Phil, I was just curious as it saves working one directory at a time. It is surprising that the coding is simple enough for you to do, but working out the appropriate syntax is harder for you, I guess there are conflicts with other arguments and possibly a lack of free characters for the argument? If you are happy enough to make this change then I’m sure it will be useful to many.