I am trying to convert a bunch of images to thumbnails that might be in several subdirectories, and save a copy of the image as a thumbnail inside the subdirectory, but I can't figure out the syntax. Any advice would be welcome.
convert test/*/*.jpg -50x50 test/*/*_thumb.jpg
A shell loop should also do:
Or with Bash's
globstar
, which is better if the files can be on arbitrary directory levels:${file%.jpg}
takes the value of the variablefile
and removes the string.jpg
from the end. (see BashGuide on parameter expansions)You should use find for finding all files you need.
And then you should rename files with name *.jpg_thumb to *_thumb.jpg by using:
Note that -50x50 is not a legal parameter for convert. You should use
-resize
parameter with value50x50
like in example above.