Is it possible to change *.CR2 filename in date and custom text?

Started by Andries78, July 08, 2019, 09:55:26 AM

Previous topic - Next topic

Andries78

Hello everybody,

This is my first post and I hope someone can help me.

I have a lot of *.CR2 files and I want to rename it to date-time-and-custom-text.
But how should I do that? This work but without custom text.

exiftool -r -d %Y/%m/%d/%Y%m%d-%H%M%S%%-c.%%e "-filename<CreateDate" *.CR2

Example: "IMG_3440.CR2" --> "20190708-085938-By-Andries.CR2"

Is that possible?


Greetings,
Andries.

Phil Harvey

Hi Andries,

Try this:

exiftool -r -d %Y/%m/%d/%Y%m%d-%H%M%S "-filename<${CreateDate}-By-Andries%-c.%e" -ext cr2 .

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

Andries78

Thank you for your very quick response.
this works great!

Is this also possible with 2 variable in a cmd file?

e.g. batchrename.cmd d:\source-photo-directory e:\destination-photo-directory

(I think in this direction but this is not working yet)

batchrename.cmd

exiftool -r -d %Y/%m/%d/%Y%m%d-%H%M%S "-filename<${CreateDate}-By-Andries%-c.%e" -ext cr2 %1 %2


%1 = source-photo-directory
%2 = destination-photo-directory

Or do I have to create a new question for this?

Greetings,
Andries ;D

Phil Harvey

You would do it like this in a .bat file:

exiftool -r -d %%Y/%%m/%%d/%%Y%%m%%d-%%H%%M%%S "-filename<${CreateDate}-By-Andries%%-c.%%e" -o %2 -ext cr2 %1

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

Andries78

Thanks again for your very quick response!

It almost works. The source files are going well.
The destination folder goes wrong.

The target files go to the current location where I run the bat file.

e.g. If I run "batchrename.cmd" in "c:\temp" with the followed params:

batchrename.cmd d:\source-photo-directory e:\destination-photo-directory

The *.cr2 files are copied to "c:\temp"


(It seems that the exiftool does not do anything with the destination location.)

Also without a batchfile:

exiftool -r -d %Y/%m/%d/%Y%m%d-%H%M%S "-filename<${CreateDate}-By-Andries%-c.%e" -o e:\destination -ext cr2 d:\source

The destination location is: c:\temp  ???


Greetz,
Andries

Phil Harvey

Oh, right.  Your FileName specification contains a directory, so it overrides the directory of -o.  But the -o is still needed so the file gets copied.  This should fix it:

exiftool -r -d %%Y/%%m/%%d/%%Y%%m%%d-%%H%%M%%S "-filename<%2/${CreateDate}-By-Andries%%-c.%%e" -o . -ext cr2 %1

Remove the -o . if you want to move the file instead of copying it.

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

Andries78

Thanks! This Works 100%

I'm happy. :D
Thanks again.

Greetings,
Andries.