在目录中查找所有图像文件大小和宽度

san*_*prb 3 shell shell-script imagemagick files

我试图在我的目录中找到所有 .png .jpg 和 .gif 文件。我正确获取文件大小,但无法imagemagick在日志文件中获取图像宽度(我正在使用)。

脚本代码

#!/bin/bash
for d in ./*; 
do 
    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 
done
Run Code Online (Sandbox Code Playgroud)

meu*_*euh 5

使用时,identify -format如果需要,必须显式添加换行符。没有它,您的所有宽度都在一行上,如果第一个与您的 awk 条件不匹配,您将什么也看不到。

...-exec identify -format '%w %h %i\n' '{}' \; ...
Run Code Online (Sandbox Code Playgroud)