Hi.
First excuse my bad english. I hope you can understand what I mean.
I will change all the filenames of my fotos like that:
CreateDate_Directory_ActualFilename.ActualExtension
For example I will change the file 'test.jpg' from the folder 'Pics'
With this command
exiftool -r -FileName'<DateTimeOriginal' -d %Y%m%d_%H%M%S_%%f.%%e test.jpg
I get the result
20110709_201815_test.jpg
That's ok :-)
But with this command
exiftool -r -FileName'<DateTimeOriginal' -d %Y%m%d_%H%M%S_%%d_%%f.%%e test.jpg
I get the result
20110709_201815__test1.jpg (here are only 2 underlines)
and not (what I will)
20110709_201815_Pics_test1.jpg
Can anyone help me with the correct syntax.
Thanx and regards
Hans
Hi Hans,
What you are doing won't work for 2 reasons:
1) You didn't specify a directory name for "test.jpg", so %%d is an empty string.
2) The directory will end with a slash, and writing a file name containing a slash will also change the directory.
Instead, something like this:
exiftool -r '-filename<${datetimeoriginal}_${directory;tr(/)(-)}_$filename' -d %Y%m%d_%H%M%S DIR
You should specify DIR exactly as you want it to appear in the file name, and the "tr(/)(-)" function translates all "/" to "-" so the file name won't contain slashes.
- Phil
Hi Phil
Thank you for this quick response. I hope I understand what you mean with the DIR at the end.
I did now the following:
I have one file: /home/myname/Pics/testpic.jpg
and another: /home/myname/Pics/SubPics/testsubpic.jpg
I did this command:
exiftool -r '-filename<${datetimeoriginal}_${directory;tr(/)(-)}_$filename' -d %Y%m%d_%H%M%S /home/myname/Pics
(I wish to get /home/myname/Pics/20110709_201815_home-myname-Pics_testpic.jpg
and /home/myname/Pics/PicsSub/20110709_201815_home-myname-Pics-PicsSub_testsubpic.jpg
Now exiftool renamed and moved my pictures to new directories:
/home/myname/20110709_201815/home/myname/Pics/PicsSub;tr( with the file ")(-)}_testsubpic.jpg"
and
/home/myname/20110709_201815/home/myname/Pics;tr( with the file ")(-)}_testpic.jpg"
In the original directories /home/myname/Pics and /home/myname/Pics/PicsSub are no more files.
Do you have any idea what still goes wrong?
Regards,
Hans
Hi Hans,
Try updating to the current version of ExifTool. The tr()() feature was added in version 9.15.
Any version after this should work, but you will have a leading "-" on the directory name in your file names. You can remove this by specifying a relative directory "home/myname/Pics", or using "${directory;tr(/)(-);s(^-)()}" in your command.
- Phil
Hi Phil
Thanks a lot. I updated to version 9.25 and your help works great.
Regards from Switzerland
Hans