Bulk sort photos into folder year and then camera model - +increment duplicates

Started by zorkiii, January 23, 2023, 05:12:18 PM

Previous topic - Next topic

zorkiii

Hi, I came across this command recently from another thread:

exiftool.exe -r -d %Y "-directory<$CreateDate/${model;}" .

This is working fine except whenever there are duplicates, I am looking to have the above handle a duplicate by adding a -1 or whichever multiple is needed. I believe that's the following:

%-c.%ue"

I tried adding that to here:

exiftool.exe -r -d %Y "-directory<$CreateDate/${model;}%-c.%ue" .

But it wrote the folder name as year.jpg and the camera model folder with jpg or something strange. I am missing how to properly use the numbering for the example above.

Also one last piece of information, what I am doing is currently dragging some older backups of multiple photos that I've renamed using the myargs.txt that Phil provided me in this thread: https://exiftool.org/forum/index.php?topic=14367.0

-P
-d
%Y-%m-%d-%Hh%Mm%S
-FileName<${FileModifyDate}%-c.%ue
-FileName<${CreateDate}%-c.%ue
-FileName<${DateTimeOriginal}%-c.%ue
-FileName<${FileModifyDate}_${Model;}%-c.%ue
-FileName<${CreateDate}_${Model;}%-c.%ue
-FileName<${DateTimeOriginal}_${Model;}%-c.%ue
-FileName<${FileModifyDate}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${CreateDate}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${DateTimeOriginal}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${FileModifyDate}_${Model;}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${CreateDate}_${Model;}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${DateTimeOriginal}_${Model;}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue

I am now hoping to move these large folders and subfolders of photos into new folders by Year, and then subfolders inside each year named after the exif camera model, and then the photos themselves inside the camera model. Again the script  -r -d %Y "-directory<$CreateDate/${model;}" . does seem to handle it but keeps prompting that filename already exists whenever there is a collision, and I have to rerun the source folder again. I am keeping the duplicates right now to try to sort through which versions I have and determine how to handle them.

Appreciate any tips - also if the -r -d %Y "-directory<$CreateDate/${model;}" . is not the best method to do what I am looking to do I appreciate any advice or changes. However I have already sorted/moved a ton of photos using this method and have several days of effort into it, for better or worse. Thanks.

grimacing-visor

Noob here so govern yourself accordingly, but you're adding the counter and extension to the folder name which is the wrong parameter.  I've been adding it to the date parameter like so:

-d "%Y%m%d_%H%M%S%%-c.%%e"

StarGeek

Quote from: grimacing-visor on January 23, 2023, 08:36:58 PMI've been adding it to the date parameter like so:

-d "%Y%m%d_%H%M%S%%-c.%%e"

This won't work because they want Model in between the date and the extension.
* 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).

StarGeek

Quote from: zorkiii on January 23, 2023, 05:12:18 PMI am looking to have the above handle a duplicate by adding a -1 or whichever multiple is needed. I believe that's the following:
%-c.%ue

The %-c adds a (hyphen)(number) counter when needed.  The %ue is %e for the extension with the u modifying it so that it will be upper case, e.g. .JPG/.NEF/.TIF.  See the Advanced features section of the -w (-TextOut) option.

QuoteI tried adding that to here:

exiftool.exe -r -d %Y "-directory<$CreateDate/${model;}%-c.%ue" .

But it wrote the folder name as year.jpg and the camera model folder with jpg or something strange.

You need to list the exact result, otherwise there's no way to figure out what the problem here.

But the obvious thing is that you're writing to the Directory tag, which of course is going to create a directory which includes the extension due to the .%ue part. What you seem to want to do is write the filename

exiftool.exe -r -d %Y "-Filename<$CreateDate/${model;}%-c.%ue" .

But this is going to create a directory full of files with only the Model name, a copy number, and the extension, which seems odd.

QuoteI am now hoping to move these large folders and subfolders of photos into new folders by Year, and then subfolders inside each year named after the exif camera model, and then the photos themselves inside the camera model.

Ok, then I think what you actually want would be
exiftool.exe -r -d %Y "-Filename<$CreateDate/${model;}/%f%-c.%ue" .

This will move into a directory by year, subdirectory by model, keep the original base filename and add a count if needed, then add the uppercased extension.
* 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).

zorkiii

@StarGeek thank you for the explanation and example you provided. It works well and appreciate the help!

pc14

Above command (exiftool.exe -r -d %Y "-Filename<$CreateDate/${model;}/%f%-c.%ue") works great. But.. how can I change it so that it sorts like this:

DIRECTORY YEAR
DIRECTORY MONTH
DIRECTORY CAMERAMODEL
original filenames inside (with the uppercase extension)

so basically introduce one more subfolder being the month prior to the camera model subfolder.

hope it clear ! thanks

Phil Harvey

exiftool.exe -d %Y/%m "-directory<$CreateDate/${model;}" .

I've removed the -r because the output directories ("YYYY/mm/Model") go into the current folder ("."), which is the same as the input directory, which would cause files that have already been moved to be reprocessed.  It would be better to have a different output or input root 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 ($).