I've tried the below to search a folder of images for the Color Mode "Grayscale"
exiftool -ColorMode -if "-$Grayscale" H:\ > gray.csv
The file is created, but the output says 0 image files read
Any ideas if this is possible?
The command as written is looking for the existence of a tag with the name "Grayscale", which doesn't exist (at least I don't think it does).
You have to compare the tag you're searching for to the value that is in the file. The version looks for a value of exactly "Grayscale", case sensitive.
exiftool -if "$ColorMode eq 'Grayscale' " -ColorMode H:\ >gray.csv
Alternatively, you could use regex and do a case insensitive comparison
exiftool -if "$ColorMode=~/Grayscale/i" -ColorMode H:\ >gray.csv
These commands would be for using Windows CMD. If you're using PowerShell (or Mac/Linux), then swap the double/single quotes.
Additionally, you might want to add the -csv option if you are looking for a CSV-formatted output.
- Phil
I tried both examples, and added the -csv, but I am getting the following that is not finding Grayscale
exiftool -csv -r -if "$ColorMode eq 'Grayscale' " -ColorMode H:\ >gray.csv
exiftool -csv -r -if "$ColorMode=~/Grayscale/i" -ColorMode H:\ >gray.csv
1 files failed condition
1 image files read
Here is a link to the output when dropping a Grayscale file onto exiftool (showing the Grayscale output)
https://nimb.ws/TWr5Pe
Thanks
It works correctly here in CMD. Did you see the last line of my post?
C:\>exiftool -csv -r -if "$ColorMode eq 'Grayscale' " -ColorMode y:\!temp\Test4.jpg
SourceFile,ColorMode
y:/!temp/Test4.jpg,Grayscale
C:\>exiftool -csv -r -if "$ColorMode=~/Grayscale/i" -ColorMode y:\!temp\Test4.jpg
SourceFile,ColorMode
y:/!temp/Test4.jpg,Grayscale
I'm not sure what I was doing wrong but I have it working now with the below. I think it was something to do with the csv export,
exiftool -csv -r -if "$ColorMode eq 'Grayscale' " -ColorMode -ext jpg H:\ > colormode2.csv
Thank you both for your assistance. This is very useful because I am going through folders with over 500K images.