You can also watch this video at YouTube (but with ads).
Using a Shell Script to Batch Process an Image
Comments: 8 Responses to “Using a Shell Script to Batch Process an Image”
Comments Closed.
You can also watch this video at YouTube (but with ads).
Absolutely fascinating - so good to see a technical / programming tip every so often! More, please, Gary!
Very nice!
So you don't have to make the file executable with chmod anymore (or did I miss that step)?
Steven: You only have to make it executable if you want to run it from the Finder. In this example, we are running it from the Terminal.
Thanks for these wonderful tutorials.
A question.
I did exactly as explained, but the terminal denies me permission:
MacSilvio: Ridimensiona immagine silviomarcis $ ./ProcessaImmaginee.txt
-bash: ./ProcessaImmagine.txt: Permission denied
Naturally, I am logged in as a Director.
I tried to put before the SUDO command but the result is the same.
How do I solve?
Thank you
Translated from Italian with Google. Sorry
Silvio: Do you mean you are logged in as an "administrator?" If so, it should work. But perhaps you have something else going on that is preventing it. If you are feeling adventurous, look into using the chmod command to change the permissions on that file so it will run.
Gary: You were right, I added the executable property to the file and it does not give me that error anymore. But another."Warning: "Acitrezza.jpg" not a valid file - skipping
Error 4: no file was specified"I tried with other files but the result is the same.This is the listing of the txt file:
#! / Bin / bash
FN = "Acitrezza"
for SIZE in 29 40 48 50 57 58 60 72 75 76 80 87 100 114 120 144 152 167 180 512 1024
do
sips -Z $ SIZE "$ {FN} .jpg" --out "$ {FN} $ {SIZE} .jpg"
done
Thanks
Silvio: It looks like you have all sorts of extra spaces in your code. There shouldn't be any spaces after the $ characters and before the { brackets. There are also extras spaces in your first line too, which is probably why you couldn't get the code to run in the first place. And make sure the quotes are all straight quotes, not curly ones, though that may have happened when you pasted it in the comments field.
Gary: They were the quotes. Everything's ok, it works.
Thanks 👍