对于初作的升级, 现在缩图脚本支持多选择了: 在文件管理器当中选择多个图片, 点击右键, 在Scripts下选择执行脚本就可以了!
附脚本:
#!/bin/bash #Multiple selection support! for param in "$@" do #Check if it's a file if [ -f "$param" ] then #get directory dir=`dirname "$param"` #Check if it's a jpg or jpeg file if echo $param |grep -q ".jpg" || echo $param |grep -q ".jpeg" || echo $param |grep -q ".gif" || echo $param |grep -q ".png" then convert -resize 1024x1024 "$param" "$dir/1024px-$param" else continue fi else echo "Is this an image?" fi done
要点是$@这个参数, 其实是把全部参数作为一个list来使用的, 非常方便. 😀
UPDATE1: 用regexp重写一下扩展名判断部分
regexp参考链接: Regular Expressions In grep
#!/bin/bash #Multiple selection support! for param in "$@" do #Check if it's a file if [ -f "$param" ] then #get directory dir=`dirname "$param"` #Check if it's a jpg or jpeg file if echo $param |grep -E -q "\.jpg|jpeg|png|gif$" then convert -resize 1024x1024 "$param" "$dir/1024px-$param" else continue fi else echo "Is this an image?" fi done