mac terminal isn't recognizing wild card

by abbood   Last Updated July 11, 2018 12:01 PM

I'm trying to write a quick script that shrinks all the images on a folder.. from here i got this:

for i in *.png; do sips -Z 800 "${i}" --out "${i%png}"; done

but then I keep on getting this error:

Warning: *.png not a valid file - skipping
Error 4: no file was specified
Try 'sips --help' for help using this tool

What am I doing wrong? this is my bash version:

bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.


Answers 1


The script needs to be executed inside the folder that contains the pictures. If by any means there is no .png file inside the current folder the loop assigns *.png to the variable i. As a result, sips tells you it is not a valid file, which is correct.

Kevin K.
Kevin K.
July 11, 2018 11:20 AM

Related Questions


tmux prevents bash from seeing ctrl commands

Updated September 21, 2018 21:01 PM

Unable to launch application in tmux

Updated October 26, 2017 13:01 PM

Close terminal bash pane

Updated April 13, 2017 10:01 AM