1
\$\begingroup\$

I have used EXIF's Rating interval for ranking photos in my collection. My photo collection is organized in directories in the form YYYY/YYYY-MM-DD Description/Filename.jpg, e.g. 2020/2020-12-31 New Year's Eve/DSC_1234.jpg.

I wish to export all my photos to be printed, and used as a slideshow. To achieve this, I have tried ExifTool. This command generates quite useful filenames, as the photo print shop prints the file names on the back of the photos (and I can play the slide show alphabetically):

exiftool . -if '$Rating ge 4' -recurse -out 'export/%D - %F'

This gets me close to what I want. However, the variable %D contains the entire directory path, eg. 2020/2020-12-31 New Year's Eve, but I want all files to be in a single folder.

1) How do I avoid generating any subdirectories within the export-folder?

Also, the photo organization software I used generated backup files with a prepended period, eg. .DSC_1234.jpg.

2) How do I skip files starting with a .?

Note: I'm using ExifTool on OS X.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

First, you probably want to use
-if '$Rating>=4'
instead, as that is a numeric comparison while ge is a string comparison. It won't cause any problems for this command, but if you were, for example, using RatingPercent instead of Rating, then an entry of 10 would be less than 4 in a string comparison. Note that while Rating is generally assumed to be 0-5, exiftool will happily set it to a value of 10, 100, 1,000 or more if that is what you desire. And all these would be less than 4 if you used ge.

To avoid generating any subdirectories, simply remove the %D. But I suspect that what you really mean is that you want to include part of the directory in the filename. If that is the case, you can edit the parts of the directory path for the % tokens. See the Advanced features section of the -w (-TextOut) option. To include only the original directory that contains the files, you would use %-1:D

To ignore files that start with a dot, use the -i (-Ignore) option with a value of HIDDEN, e.g. -i HIDDEN

\$\endgroup\$
1
  • \$\begingroup\$ Thanks! I ended up with this command exiftool . -if '$Rating >= 4' -ignore HIDDEN -recurse -out 'export/%-1:D - %F' \$\endgroup\$
    – Kristian
    Commented Dec 19, 2021 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.