I am trying to recursively loop through all directories and print a full path list of all jpg files that are not perfectly square.
here is something I was using to find directories between 2 and 6 deep that are missing a cover.jpg:
find . -mindepth 2 -maxdepth 6 -type d '!' -exec test -e "{}/cover.jpg" ';' -print
I then modified that to try and find the non square images:
find . -mindepth 2 -maxdepth 6 -type d '!' -exec identify -format '%[fx:(h == w)]' "{}/cover.jpg" ';'
The above is very close to working, it starts outputting 0 and 1 based on the result of being square or not, but the 0 or 1 is output to the same line instead of a new line, and it just continues on the same line as it checks the files.
1111111111111111111111111111111001100101101110111001110010101001011000001101
I was thinking if it output a single 1 or 0 per line I could grep it if 0 and print the file path.
I don't have a ton of Bash experience, and so far I am having no luck. Appreciate any help.
From the imagemagick documentation, I think you can just append the newline (and path) to the format:
find . -mindepth 2 -maxdepth 6 -type d '!' -exec \
identify -format '%[fx:(h == w)] %d/%f\n' "{}/cover.jpg" ';' |\
sed -n '/^0 / s///p'
(Untested code as I don't have imagemagick installed. The sed
command implements the grep and strips the leading zero that was added.)