Rename based on date when file already exists

Started by magarlick, June 11, 2018, 02:10:12 PM

Previous topic - Next topic

magarlick

Hi guys

I'm using this command to rename JPGs and their matching XMPs to the data taken:

exiftool "-filename<filemodifydate" "-filename<datetimeoriginal" -d "%Y-%m-%d_%H-%M-%S.%%e" *.jpg *.xmp

I'm getting errors because some of the photos have exactly the same time, so it won't rename them. How can I get around this? Increment the times by a few seconds, say?

Many thanks.

StarGeek

Take a look at the %c variable (see the docs for -w option).  This will add a counter number when there's a duplicate name.

So if you change your date option to -d "%Y-%m-%d_%H-%M-%S%%-c.%%e", two files with the same timestamp would end up like this:
2018-06-11_11-39-46.jpg
2018-06-11_11-39-46-1.jpg

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

magarlick

Excellent, many thanks.

ANd how can I include a string in the new file name, prefixed at the beginning? Such as

France 2018-08-23_12_24_23.jpg

Cheers.

Phil Harvey

Is this what you mean?:

-d "France %Y-%m-%d_%H-%M-%S%%-c.%%e"

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