Main Menu

Cleaning up a mess

Started by slickdawg, November 13, 2020, 02:43:57 PM

Previous topic - Next topic

slickdawg

One folder, with numerous sub-folders, filled with images from different model cameras.  Some cases where the Memory card was used in a Canon 5D then moved to 7D, so you have instances in one directory where

IMG_0001.JPG - 5D
IMG_0002.JPG - 5D
IMG_0003.JPG - 5D
IMG_0004.JPG - 7D
IMG_0005.JPG - 7D
IMG_0006.JPG - 5D

And there are some images that are scans, others that just have little to no, or even a few cases of corrupt metadata. 


What I'm thinking may be a good way to organize this is to have exiftool recursively sort the entire directory structure into chronological order, so there's something like:

2008\datetimecreate_model.jpg
2009\datetimecreate_model.jpg
2010\datetimecreate_model.jpg


File rename in YYMMDD_HHMMSS_Model format, and replace any spaces in the model with an underscore:

exiftool '-filename<${DateTimeOriginal}_${Model;tr/ /_/}.jpg' -d %Y%m%d_%H%M%S%%-c /tmp/x.jpg

turns /tmp/x.jpg into /tmp/20130826_072742_Canon_EOS_7D.jpg 

Do the same, but store the file in a directory based on the YYYY (year) value:

exiftool '-filename<${DateTimeOriginal}_${Model;tr/ /_/}.jpg' -d /tmp/%Y/%Y%m%d_%H%M%S%%-c /tmp/x.jpg

turns /tmp/x.jpg into /tmp/2013/20130826_072742_Canon_EOS_7D.jpg


Doing that recursively would handle all the camera images that have valid metadata.  What about the leftovers?   Is there a way to have exiftool dump them in a separate folder?   So when it's done, there's basically

2009\
2010\
2011\
2012\
leftovers\






StarGeek

From note 1 on the Tag Value docs:
    Many tag values may be assigned in a single command. If two assignments affect the same tag, the latter takes precedence

So just put something to move the files into the leftover folder before anything else.  As an example
exiftool '-Filename=/path/to/leftovers/%F' '-filename<${DateTimeOriginal}_${Model;tr/ /_/}.jpg' -d /tmp/%Y/%Y%m%d_%H%M%S%%-c /tmp/x.jpg

If the file contains a DateTimeOriginal and a Model tag, then it will be sorted properly.  If it is missing one of those, it will fall back on the move into the leftovers directory part of the command.

Further details, see the -w (textout) option for details on the %F and Common Mistake #5c on why the first part uses an equal = sign.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

slickdawg

Thank you StarGeek! 


One follow up question - is it possible to have exiftool make copies of everything in a new directory and leave the source files alone? 

StarGeek

Yes, with the -o (-out) option.  Add -o . to the command.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype