File numbering not separated for each file format

Started by dwbmb, March 21, 2016, 07:31:59 PM

Previous topic - Next topic

dwbmb

Hello, in documentation I found this:

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, the copy number is omitted from the first file of a given name, 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 ...
    -w I.%.3uc.txt    # I.AAA.txt, I.AAB.txt, I.AAC.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


But what I would like to do is more something like this:
F-0001.png, F-0002.jpg, F-0003.bmp ...
So file numbering (001,002...) continues no matter what file extensions it has. Anyone know how to do that?

I currently use this command to rename file by date and number
exiftool "-FileName<CreateDate" -d %%Y%%m%%d%%%%-.3nc.%%%%e . -overwrite_original -r
but it starts from beginning for each file type (photos and videos).

Phil Harvey

#1
Tricky.  The %c logic increments the number only if the file exists.  I can't think of an easy way to do this other than to sacrifice the extension and add it back again later:

exiftool "-FileName<CreateDate" -d %%Y%%m%%d%%%%-.3nc.xxx -r .
exiftool "-FileName<%%f.$filetypeextension" -ext xxx -r .


(Note to others: These commands have doubled "%" characters for use in Windows .BAT files)

- Phil

StarGeek's post made be realize that I mis-read the original post.  I was thinking you wanted all files with the same name to have the same number, regardless of extension.  StarGeek's idea of using FileSequence should so what you want. This may also be done with %1.3C (capital "C"), which is a bit simpler.
...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 ($).

StarGeek

Maybe something like this?
exiftool -r -FileOrder CreateDate "-FileName<$CreateDate-${FileSequence;$_=sprintf('%03d', $_+1 )}.%e" -d %Y%m%d

I added the FileOrder option because it seemed to make a bit more sense.  Otherwise you could have File1.jpg with a create date after File2.jpg and your final sequence might end up 20120929-002.jpg, 20130718-001.Jpg.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

StarGeek

Quote from: Phil Harvey on March 22, 2016, 08:24:06 AM
Edit:  StarGeek's post made be realize that I mis-read the original post.  I was thinking you wanted all files with the same name to have the same number, regardless of extension.  StarGeek's idea of using FileSequence should so what you want.

I came back because I started to think that maybe I misread it and was going to change things.  :D  For now, I'll just leave it until there's more info.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Hmm.  I read the original post again, and now I think that maybe I was right the first time. :P

My last post will number files like this:

F-001.png, F-002.jpg, F-003.bmp
G-001.png, G-002.jpg, G-003.bmp

Whereas StarGeek's suggestion will do something like this:

F-001.png, F-002.jpg, F-003.bmp
G-004.png, G-005.jpg, G-006.bmp

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

dwbmb

OK, now even I don't know what exactly I wanted to do :D Just kidding. I think  that Phil is correct, I will test it out back home.

To be more accurate, I wanted turn these (made up examples):

DSC_0006.jpg, IMG18006.jpg, MOV0008.mp4

into this:

20160330_001.jpg, 20160330_002.jpg, 20160330_003.mp4
instead of this
20160330_001.jpg, 20160330_002.jpg, 20160330_001.mp4