ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Andries78 on July 08, 2019, 09:55:26 AM

Title: Is it possible to change *.CR2 filename in date and custom text?
Post by: Andries78 on July 08, 2019, 09:55:26 AM
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.
Title: Re: Is it possible to change *.CR2 filename in date and custom text?
Post by: Phil Harvey on July 08, 2019, 10:30:08 AM
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
Title: Re: Is it possible to change *.CR2 filename in date and custom text?
Post by: Andries78 on July 09, 2019, 10:09:58 AM
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
Title: Re: Is it possible to change *.CR2 filename in date and custom text?
Post by: Phil Harvey on July 09, 2019, 10:15:04 AM
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
Title: Re: Is it possible to change *.CR2 filename in date and custom text?
Post by: Andries78 on July 09, 2019, 12:58:15 PM
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
Title: Re: Is it possible to change *.CR2 filename in date and custom text?
Post by: Phil Harvey on July 09, 2019, 03:54:08 PM
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
Title: Re: Is it possible to change *.CR2 filename in date and custom text?
Post by: Andries78 on July 10, 2019, 12:50:49 PM
Thanks! This Works 100%

I'm happy. :D
Thanks again.

Greetings,
Andries.