sorting to folders with camera model and renaming

Started by bassam, April 01, 2020, 08:30:58 AM

Previous topic - Next topic

bassam

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...

Phil Harvey

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

bassam


bassam

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.

Phil Harvey

Add -P to the command to preserve the original FileModifyDate.

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

bassam

#5
Many thanks Phil for your help and for making ExifTool..

bassam

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 ?

Phil Harvey

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

azuremonkey

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


StarGeek

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, 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.  It works similarly to the the -d option.  See the example under that link.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).