ExifTool Forum

ExifTool => Newbies => Topic started by: ed102 on February 23, 2014, 01:10:34 AM

Title: Recursively renaming files
Post by: ed102 on February 23, 2014, 01:10:34 AM
Hi

I have several thousand photos sorted in year, month, day folders all with various names and want to change the name of them all to the following format:

ed-00000.jpg, ed-00001.jpg, ed-00002.jpg etc

Using the following command in Linux

exiftool -filename='ed%-.5c.jpg' -r dir

recursively changes all files but every time it enters a new directory it starts the renaming from 00000 again.

How do I get it to continue the sequence when entering the next directory?


Title: Re: Recursively renaming files
Post by: Phil Harvey on February 23, 2014, 10:08:42 AM
To do this you must change gears and use a couple of different ExifTool features:

exiftool '-filename<ed-${filesequence;$_=sprintf("%.5d",$_)}.jpg' -ext jpg -r DIR

Here I added -ext jpg just in case there are other types of files around.

- Phil
Title: Re: Recursively renaming files
Post by: ed102 on February 23, 2014, 03:29:30 PM
Thanks for that Phil works great but it sometimes doesn't descend into the directories in date order so the file numbering is out.

e.g. In the 2013 directory it will rename the 05 directory before 03 directory.

Is there a way to prevent this?


Title: Re: Recursively renaming files
Post by: Phil Harvey on February 23, 2014, 05:43:31 PM
Unless you specify a different order, the order for a file list is system dependent (but usually alphabetical on Unix systems).

However, you can specify the order with ExifTool.  First sort on Directory, then FileName:

exiftool -fileorder directory -fileorder filename ...

I think this should do what you want.

- Phil
Title: Re: Recursively renaming files
Post by: ed102 on February 24, 2014, 12:26:04 AM
Cant try it right now, but that seems to be what I am after.

Thanks again for the quick help, much appreciated  :)

Ed