ExifTool Forum

ExifTool => Newbies => Topic started by: bassam on April 01, 2020, 08:30:58 AM

Title: sorting to folders with camera model and renaming
Post by: bassam on April 01, 2020, 08:30:58 AM
Good Day..
first of all.. please, excuse my bad English and my newbie question.
I have a large family photos archive (from 2007) but I was too lazy to organize every thing so now I'm stuck with many folders with a lot of photos from many sources..

I tried PhotoMove at first (told you I'm not that smart to use exiftool) but I got a problem with non-English characters.. so back to EXifTool..


I've manged to do this:

exiftool -r -o . "-Directory<FileModifyDate" "-Directory<DateTimeOriginal" -d "E:\TargertFolder/%Y/%m/%d/" E:\Source

to copy the photos using date form: Modify Date or Original Date, and put them in folders by: Year/Month/Day..

I tried to add camera Model like this:

exiftool -r -o . "-Directory<$FileModifyDate/${model;}" "-Directory<$DateTimeOriginal/${model;}" -d "E:\TargertFolder/%Y/%m/%d/" E:\Source

but not all photos have camera model info in the EXIF.

my question here, is it possible to use model as optional location, if it's not available ExifTool will copy to Year/Month/Day without model and when it's available Year/Month/Day/Model ??
and can I rename photos while copying them ?

many thnaks...
Title: Re: sorting to folders with camera model and renaming
Post by: Phil Harvey on April 01, 2020, 10:16:29 AM
In the same way that you fall back to using FileModifyDate if DateTimeOriginal is not available, you can fall back to using no Model name if it isn't available.  You can do it like this:

exiftool -r -o . "-Directory<FileModifyDate" "-Directory<DateTimeOriginal"  "-Directory<$FileModifyDate/${model;}" "-Directory<$DateTimeOriginal/${model;}" -d "E:\TargertFolder/%Y/%m/%d/" E:\Source

You can rename while copying by writing FileName with the full path name including the desired new file name instead of writing Directory.

- Phil
Title: Re: sorting to folders with camera model and renaming
Post by: bassam on April 01, 2020, 04:42:02 PM
Many thanks.. I'll try it today.

thanks again.. :)
Title: Re: sorting to folders with camera model and renaming
Post by: bassam on April 02, 2020, 02:17:11 AM
Quote from: Phil Harvey on April 01, 2020, 10:16:29 AM
In the same way that you fall back to using FileModifyDate if DateTimeOriginal is not available, you can fall back to using no Model name if it isn't available.  You can do it like this:

exiftool -r -o . "-Directory<FileModifyDate" "-Directory<DateTimeOriginal"  "-Directory<$FileModifyDate/${model;}" "-Directory<$DateTimeOriginal/${model;}" -d "E:\TargertFolder/%Y/%m/%d/" E:\Source

You can rename while copying by writing FileName with the full path name including the desired new file name instead of writing Directory.

- Phil

I used the code, But I noticed that FileModifyDate changed for all files (I didn't do the rename only copying to folders).. is that normal ? I know copying files don't change the modify date in the new file only the create date.
Title: Re: sorting to folders with camera model and renaming
Post by: Phil Harvey on April 02, 2020, 06:54:41 AM
Add -P to the command to preserve the original FileModifyDate.

- Phil
Title: Re: sorting to folders with camera model and renaming
Post by: bassam on April 03, 2020, 07:38:28 AM
Many thanks Phil for your help and for making ExifTool..
Title: Re: sorting to folders with camera model and renaming
Post by: bassam on April 03, 2020, 08:02:06 AM
It seems that everything is working except when the file is already exists in the destination & I don't know if it's the same name or same photo. I tried to find if it's possible to copy and add number or something if the file is already exists but I failed.. is this possible ?
Title: Re: sorting to folders with camera model and renaming
Post by: Phil Harvey on April 03, 2020, 08:24:40 AM
To add a number you must also write the file name, and add "%-c" for a copy number with a leading dash if the same-named file already existed.  So try this:

exiftool -r -o . "-FileName<$FileModifyDate/%f%-c.%e" "-FileName<$DateTimeOriginal/%f%-c.%e"  "-FileName<$FileModifyDate/${model;}/%f%-c.%e" "-FileName<$DateTimeOriginal/${model;}/%f%-c.%e" -d "E:\TargertFolder/%Y/%m/%d" E:\Source

- Phil
Title: Re: sorting to folders with camera model and renaming
Post by: azuremonkey on September 02, 2020, 09:18:47 AM
Hi Phil. Thanks for creating this tool. I am a Mac User. Using this I am able to copy files from "FromImageTest" folder to "ToImageTest" folder. However the file names do not change. Am I missing something?
exiftool -r -P -o . '-FileName<$FileModifyDate/%f%-c.%e' '-FileName<$DateTimeOriginal/%f%-c.%e'  '-FileName<$FileModifyDate/${model;}/%f%-c.%e' '-FileName<$DateTimeOriginal/${model;}/%f%-c.%e' -d '/Users/user/Desktop/ToImageTest/%Y/%m/%d' /Users/user/Desktop/FromImageTest

Title: Re: sorting to folders with camera model and renaming
Post by: StarGeek on September 02, 2020, 10:51:55 AM
Your command doesn't change the filenames, only the directory path.  The %f is replaced with the current filename, so if you want to change the filename to something else, you need to replace the %f with the pattern you want to use.

Assuming you want the filename to be based upon the date and since you're already using the -d (dateFormat) option (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat), you won't be able to format the filename that way, because you can't have two -d options.  You'll have to use the DateFmt helper function (https://exiftool.org/exiftool_pod.html#Helper-functions).  It works similarly to the the -d option.  See the example under that link.
Title: Re: sorting to folders with camera model and renaming
Post by: azuremonkey on September 02, 2020, 03:07:47 PM
Thank you. It worked.