Reputation: 3
I want to automate convert image file of PDF to eps file with ImageMagick. And I would like to be able to do this with drag and drop. So, I'd like to create an .app file using Automator.
I tried following things.
Write the scripts below.
for f in "$@"
do
fname="${f%.*}"
convert $f $fname.eps
done
When drag and drop an image file into .app file, the following error code will be displayed.
The action "Run Shell Script" encounted an error.
How to fix it?
--
macOS Sierra(10.12)
Upvotes: 0
Views: 819
Reputation: 24439
Ensure that your environment PATH
includes the location of convert
. I would also suggest moving the file extension to fname
assignment, and quote the path names (in the event of unicode file names).
PATH=$PATH:/usr/local/bin
for f in "$@"
do
fname="${f%.*}.eps"
convert "$f" "$fname"
done
Tips
which convert
to find the correct path to your convert binary.During development, redirect convert
stderr to a log file so you can evaluate the error.
convert "%f" "$fname" 2> /tmp/my_app.log
Upvotes: 2