ExifTool Forum

ExifTool => Newbies => Topic started by: hvdwolf on December 21, 2012, 08:23:35 AM

Title: Renaming photos with auto-numbering
Post by: hvdwolf on December 21, 2012, 08:23:35 AM
I'm working on some renaming functionality for my program.
All options with createdate, model, and other (composite) tags work fine.
However, I myself have the habit to rename my photos by file date (not date/time) with an auto-numbering sequence.
I have seen the rename examples and this (https://exiftool.org/forum/index.php/topic,4531.msg21559.html#msg21559) topic.
Say I have a bunch of photos of the same date and I use the command
exiftool '-FileName<${CreateDate}' -d %Y%m%d%%-2c.%%le  *.jpg
As such this works fine with one exception (for my purposes that is). I get:

20121221.jpg
20121221-01.jpg
20121221-02.jpg
20121221-03.jpg
etc.


Is it possible to start the first one with number 01 (2c), or 001(3c), instead of the second image?
Or do I need another function, or write something myself?
Title: Re: Renaming photos with auto-numbering
Post by: Phil Harvey on December 21, 2012, 08:49:19 AM
The %c format code is very flexible.  It sounds like you want to use %-.2nc, but the exiftool application documentation (https://exiftool.org/exiftool_pod.html) describes all of the features (see the section on the -w option):

            [...]

            For %c, these modifiers have a different effects.  If a field
            width is given, the copy number is padded with zeros to the
            specified width.  A leading '-' adds a dash before the copy
            number, and a '+' adds an underline.  By default, a copy number of
            zero is omitted, but this can be changed by adding a decimal point
            to the modifier.  For example:

                -w A%-cZ.txt      # AZ.txt, A-1Z.txt, A-2Z.txt ...
                -w B%5c.txt       # B.txt, B00001.txt, B00002.txt ...
                -w C%.c.txt       # C0.txt, C1.txt, C2.txt ...
                -w D%-.c.txt      # D-0.txt, D-1.txt, D-2.txt ...
                -w E%-.4c.txt     # E-0000.txt, E-0001.txt, E-0002.txt ...
                -w F%-.4nc.txt    # F-0001.txt, F-0002.txt, F-0003.txt ...
                -w G%+c.txt       # G.txt, G_1.txt G_2.txt ...
                -w H%-lc.txt      # H.txt, H-b.txt, H-c.txt ...

            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.  The number before the decimal place
            gives the starting index, the number after the decimal place gives
            the field width.  The following examples show the output filenames
            when used with the command "exiftool rose.jpg star.jpg jet.jpg
            ...":

                -w %C%f.txt       # 0rose.txt, 1star.txt, 2jet.txt
                -w %f-%10C.txt    # rose-10.txt, star-11.txt, jet-12.txt
                -w %.3C-%f.txt    # 000-rose.txt, 001-star.txt, 002-jet.txt
                -w %57.4C%f.txt   # 0057rose.txt, 0058star.txt, 0059jet.txt

            All format codes may be modified by 'l' or 'u' to specify lower or
            upper case respectively (ie. %le for a lower case file extension).
            When used to modify %c or %C, the numbers are changed to an
            alphabetical base (see example H above).  Also, %c may be modified
            by 'n' to count using natural numbers starting from 1, instead of
            0 (see example F above).

- Phil
Title: Re: Renaming photos with auto-numbering
Post by: hvdwolf on December 21, 2012, 09:27:02 AM
Thanks.
Another feature that is explained at the -w[!] tag which I missed last time as well. I didn't expect from the rename examples and topic that I should have moved again to the -w option.

And yes: exiftool '-FileName<${CreateDate}' -d %Y%m%d%%-.2nc.%%le  *.jpg
gives exactly what I want: "date" files with the prefix ending in and starting with -01, -02 etc.

Thanks again.