I am sure this is a regular use case for exiftool. I am looking for a linux script or command line guidance.
I have a collection of raw and jpg images in multiple sub-directories. I would like to recursively scan through all sub-directories and copy into organized directories in the format: Make/Model/CreateDate/ (i.e. Nikon/D610/20201215/).
I do not wish to rename files.
I would appreciate if someone could help me out.
Thanks in advance!
This command should almost do the job:
exiftool '-directory<Nikon/${model;}/${createdate}' -d %Y%m%d DIR
The semicolon after "model" adds the default advanced formatting expression which removes illegal characters in the directory name.
The problem here is that you will get directories like "Nikon/NIKON D610/20201215/". To give you a full, working command I would have to know all of the models you plan to support, their stored model names, and the names you want for their directories. For cameras with the model name in the format "MAKE MODEL", this could work:
exiftool '-directory<${model;s/(\w)(\w+) /$1\L$2\//;tr(/\\?*:|"<>\0)()d}/${createdate}' -d %Y%m%d DIR
This looks complex, but all it is doing to Model is changing the first word in the model name to mixed case and changing the first space to a "/", then applying the default expression to remove illegal characters.
- Phil
Quote from: Phil Harvey on December 20, 2021, 07:52:10 AM
This command should almost do the job:
exiftool '-directory<Nikon/${model;}/${createdate}' -d %Y%m%d DIR
The semicolon after "model" adds the default advanced formatting expression which removes illegal characters in the directory name.
Phil,
Thank you for taking the time to read my post and providing the instruction.
I followed your direction and I ran the following command:
exiftool -o '-directory</mnt/photo_out/${make;}/${model;}/${createdate}' -d %Y%m%d -r /mnt/photo_in/
However, this will not scan the sub-directories with space in it (ie '/2019\ Florida') in the source folder "photo_in/".
Also directory name creation is unreliable... in some cases it will create directories such as '${make}' instead of 'Panasonic'.
Am I doing something wrong?
How do I fix this?
Thanks again!
Quote from: s21jb on December 21, 2021, 10:36:37 PM
However, this will not scan the sub-directories with space in it
Add the
-r option to recursively scan sub-directories. The space won't make a difference.
QuoteAlso directory name creation is unreliable... in some cases it will create directories such as '${make}' instead of 'Panasonic'.
You must have used an "=" sign instead of "<".
- Phil