Reputation: 35933
I am creating a service for finder, using automator. The service has only one item: "run shell script" and the script is this:
currentDirectory=$(pwd)
for f in "$@"; do
DIRNAME="$(dirname "$f")"
export width=$( mdls "$f" | grep kMDItemPixelWidth | tail -n1 | cut -d= -f2 )
export height=$( mdls "$f" | grep kMDItemPixelHeight | tail -n1 | cut -d= -f2 )
oneWidth=$((width / 3))
oneHeight=$((height / 3))
twoWidth=$((umWidth * 2 ))
twoHeight=$((umHeight * 2 ))
IFS='@3x' read -ra NAMES <<< "$f" #Convert string to array
basename=${NAMES[0]}
extension="${f##*.}"
fullnameOne=${NAMES[0]}.$extension
fullnameTwo=${NAMES[0]}@2x.$extension
sips -z "$oneWidth" "$oneHeight" "$f" --out "$DIRNAME"/"$fullnameOne"
sips -z "$twoWidth" "$twoHeight" "$f" --out "$DIRNAME"/"$fullnameTwo"
done
The idea is this:
@3x
, like [email protected], [email protected], etc.@2x
and @1x
versions of the files, renaming them [email protected], [email protected], file.png and ball.jpg respectively.This script you see above runs from terminal, but not from automator. On automator the script generates just one file called Users
.
What is wrong?
Upvotes: 0
Views: 146
Reputation: 72619
What is wrong?
Likely the arguments to the script. To test this hypothesis, add
printf '<%s>\n' "$@" >$HOME/debug.out
after currentDirectory=$(pwd)
.
If that doesn't help, also add set -x
and redirect stderr to someplace you can find it.
Upvotes: 1