I have an automator script that I'd like to run on a folder. I want the script to take each file in the folder and run my shell command on it. Automator is set to pass input to stdin, but I don't think I'm using stdin correctly below, can you help please?
for f in "$@"
do
java -Xmx1000m -jar /Users/myprog/myprog.jar $f
done
The special variable $@
represents all the command-line arguments provided to the script.
The for
loop steps through each one and executes the jar file each time. You could shorten the script to:
for f
do
java -Xmx1000m -jar /Users/myprog/myprog.jar "$f"
done
since the default behavior of for
is to use $@
.
You should put quotes around $f at the end of the java command in case there are spaces in the arguments.