ExifTool Forum

ExifTool => Newbies => Topic started by: yama on September 07, 2024, 08:11:36 PM

Title: How can I make this ExifTool command "Safer" ?
Post by: yama on September 07, 2024, 08:11:36 PM
Hello,

I'm in the process of trying to clean up a little over a decades worth of pictures strung across hundreds of folders. I've included the command i'm using below to take one working directory at a time, and place the images into categorized folders in the structure of YYYY\MM-MMM.

My question is - can anyone give me suggestions on how I could possibly improve this command? One thing I'm aware of but not sure if I'm seeing instances of is - if an image has the same name and gets placed into the same directory structure, I'm likely to lose data.

Any suggestions welcome. Thank you!

"exiftool(-k).exe" -r -ext jpg -ext png -ext jpeg -ext mov -ext raf -P -progress -o . -d "%Y/%m-%b" "-directory<filemodifydate" "-directory<createdate" "-directory<datetimeoriginal" "..\Pictures_Backup\working_directory"
Title: Re: How can I make this ExifTool command "Safer" ?
Post by: StarGeek on September 08, 2024, 10:10:55 AM
Quote from: yama on September 07, 2024, 08:11:36 PMif an image has the same name and gets placed into the same directory structure, I'm likely to lose data.

This will never happen. Exiftool will never overwrite an existing file with another file, except in the case of text output via the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) while using the ! modifier.

To deal with possible name collisions, you have to switch from Directory to Filename. You can include directory paths when doing so. The %c variable is used to add a copy number (see the above -w option for details).

-d "%Y/%m-%b/%%f%%-c.%%e" "-Filename<filemodifydate" "-Filename<createdate" "-Filename<datetimeoriginal" "..\Pictures_Backup\working_directory"

The filename percent variables, %f/%c/%e, need to have the percent sign doubled when used in a -d (-dateFormat) format string (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat). When used in a Windows .bat file, they need to be doubled again (see FAQ #27, My ExifTool command doesn't work from a Windows .BAT file (https://exiftool.org/faq.html#Q27)).