osx - Get folder path/content in a Mac Service -
i have nice working folder action, watermarks every picture in folder , put them in folder.
watermark=~/dropbox/business/mihalko_logo_bw.png shopt -s nocasematch f; [[ $f =~ .*\.(jpe?g|png)$ ]] || continue d="${f%/*}/wm_$(date +%y_%m_%d)" mkdir -p "$d" target="$d/${f##*/}" size=$(/usr/local/bin/identify -format '%[fx:w/4,279]' "$f") /usr/local/bin/composite -dissolve 10% -gravity southeast\ \( $watermark -geometry $size \) "$f" -quality 100 "$target" rm $f done ~/imageoptim-cli/bin/imageoptim --jpeg-mini --image-alpha --quit --directory "$d"
unfortunatelly, fa working in 1 directory. tried create service code, without success. knows modifications/automator action needed in case?
using associative array:
watermark=~/dropbox/business/mihalko_logo_bw.png shopt -s nocasematch declare -a dirs f; [[ $f =~ .*\.(jpe?g|png)$ ]] || continue d="${f%/*}/wm_$(date +%y_%m_%d)" mkdir -p "$d" dirs["$d"]="$d" target="$d/${f##*/}" size=$(/usr/local/bin/identify -format '%[fx:w/4,279]' "$f") /usr/local/bin/composite -dissolve 10% -gravity southeast\ \( "$watermark" -geometry $size \) "$f" -quality 100 "$target" rm "$f" done d in "${dirs[@]}"; ~/imageoptim-cli/bin/imageoptim --jpeg-mini --image-alpha --quit --directory "$d" done
Comments
Post a Comment