Page 1 of 1
mogrify subdirectories using wildcard
Posted: 2010-07-11T12:16:26-07:00
by robinesque
Is it possible to mogrify subdirectories using a wildcard, with a command like this:
mogrify -quality 85 '/photo1/*/*.jpg'
I found the above example on an imagemagick mailing list from 2006:
http://www.mail-archive.com/magick-user ... 00232.html
I can't get it to work on windows xp, and I don't see any references to it on imagemagick.org. Is it supposed to work?
Thanks!
Re: mogrify subdirectories using wildcard
Posted: 2010-07-11T14:53:04-07:00
by fmw42
mogrify -quality 85 '/photo1/*/*.jpg'
I don't think IM allows you to work on images in wildcard directories. But I have not tried that.
But even if you specify the directory, is /photo1/ your root directory? If not and if that is a subdirectory of your current directory then your probably want to specify './photo1/...'
I stand corrected. I tried
mogrify -format jpg test1/*/*.png
and
mogrify -format jpg ./test1/*/*.png
and
mogrify -format jpg /Users/fred/test1/*/*.png
and they each work, where I had two subdirectories, test2 and test3 in test1, each with a png file.
It did not work with either single or double quotes on my Mac OSX Tiger, IM 6.6.3.0 Q16
Re: mogrify subdirectories using wildcard
Posted: 2010-07-11T18:12:36-07:00
by anthony
NOTE: Under UNIX/LINUX/MacOSX environment: without quotes you are asking for the shell (command line) program to expand the wildcards. With quota you are passing the wildcards to ImageMagick to expand the wildcard. These are quite different, and the later will prevent you overflowing the command line buffer in some older shell implementations.
DOS does not do this expansion and just passed wild cards to the program (ImageMagick)

That is why IM can do wildcard expansion, though in some cases that could open a security hole.
Which is why security sensitive applications should sanities all input.
Re: mogrify subdirectories using wildcard
Posted: 2010-07-11T18:48:02-07:00
by robinesque
Thank you Anthony and Fred! That explains why it didn't work in DOS, and didn't work with quotes.
I did try it in a unix-type shell (cygwish80) without quotes, and still got error "invalid argument". Maybe I need a newer unix shell.