Mass renaming of files, but without recursion.

Started by Flow777, March 27, 2023, 08:59:44 AM

Previous topic - Next topic

Flow777

Good day!
My rather small problem is as follows: there is a large folder (in the following example - it is called "2"), it contains several dozen subfolders ("A", "B", "C"); I would like to perform a massive file renaming - for example, 001.jpg , 002.png, 003.jpg...

I tried using this command as:
exiftool -r -fileOrder DateTimeOriginal "-filename=%1.03C.%e" D:\2 -overwrite_original -progress
used this one too:
exiftool -r -fileOrder DateTimeOriginal "-filename=%d/%01.3C.%e" D:\2 -overwrite_original -progress
and they work great.
But when renaming, the numerical sequence of names from one folder continues to another (035.jpg, 036.png - and 0.37 - in another folder).

What can be done to rename all files nested in subfolders with a single command, but the sequence starts anew in each of them (035.jpg, 036.png - in one folder, and 001.jpg - in another folder, etc.).
Thanks!

P.s.: I tried the method from the reverse indicated here - it didn't help.

My OS: Windows 11 Pro 22H2
Exiftool version: 12.58
Type of file: *jpg, *png

Phil Harvey

From the application -w option documentation:

            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.


(emphasis added)

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

Flow777


Thanks a lot for the tip. But what will the team look like then, if not a secret?

Phil Harvey

Just add a "-" after the "%" for the "C" format specification.  eg. "%-1.03C"

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

Flow777

Unfortunately, I put a minus - but the numbering also continued...

exiftool -r -fileOrder DateTimeOriginal "-filename=%-1.03C.%e" D:\2 -overwrite_original -progress

Phil Harvey

Right.  I didn't notice you were using the -fileorder option:

        -fileOrder
            Note that files are sorted across directory boundaries
            if multiple input directories are specified.


That is a problem.  I don't see an easy work-around other that possibly renaming according to DateTimeOriginal first, then hoping the system returns files in FileName order.

Also, you don't need the -overwrite_original option if just writing FileName.

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

Flow777

#6
I solved the problem using this:
exiftool -r "-filename=%2.03nc.%e" D:\2 -progress
After all, the simplest solution is sometimes the best move.

Thanks Phil, for your help and sorry to bother you.

Phil Harvey

#7
No bother at all.  In fact, this question pointed out a problem in ExifTool that I will fix in the next version.

With version 12.59 and later you will be able to do what you want, and %-C will work with the -fileOrder option.  (Note that %-C was also broken by the -progress option, but this will be fixed as well.)

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

Flow777