I'm trying to find all .png .jpg and .gif files in my directory. I'm getting the file sizes properly but unable to get image width (I'm using imagemagick) in log file.

Script code

for d in ./*; 
    echo "listing contents of dir: $d";  
    find . -iname "*.jpg" -type f -exec identify -format '%w %h %i' '{}' \; | awk '$1<300 || $2<300'
    find . \( -name "*.jpg" -or -name "*.png"  -or -name "*.gif" \) -size "+120k" -type f  -exec ls -lah {} \; > sandip-log.txt 

When using identify -format you must explicitly add a newline if you want one. Without it, all your widths are on one line, and if the first one doesn't match your awk condition, you will see nothing.

...-exec identify -format '%w %h %i\n' '{}' \; ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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