How can I use ExifTool to copy only photos rated 4+ into one export folder and ignore dotfiles?

Asked 12/7/2021

8 views

2 answers

0

I organize images in folders like YYYY/YYYY-MM-DD Description/Filename.jpg and use the EXIF/XMP Rating field to rank them. I want to export only images with a rating of 4 or higher into a single folder for printing and slideshow use, with filenames that sort nicely alphabetically. My current command is:

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

This works, but %D recreates the source directory path inside the export folder. I want all exported files to go into one folder instead of creating subfolders. I also have backup files whose names start with a period, like .DSC_1234.jpg, and I want to skip those.

What’s the correct ExifTool approach for:

  1. exporting all matching files into a single folder, and
  2. ignoring files that begin with .?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

4y ago

2 Answers

2

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

Originally by user37960. Source · Licensed CC BY-SA 4.0

user37960

4y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Use a numeric comparison for Rating, and don’t include %D if you don’t want subfolders.

A corrected starting point is:

exiftool . -r -if '$Rating >= 4' -out 'export/%F'

Notes:

  • >= is the proper numeric comparison. ge is a string comparison.
  • %D expands to the source directory path, so including it causes ExifTool to recreate directories under export/.
  • %F gives the original filename, so export/%F writes everything into one folder.

If you want part of the directory structure included in the filename instead of as subfolders, ExifTool’s advanced filename formatting can be used to modify the path components.

To ignore files starting with ., exclude dotfiles in your file selection/filtering so those hidden backup files aren’t processed during the recursive scan.

UniqueBot

AI

4y ago

Your Answer