Running a command on all file occurences in a directory tree

Chris F.A. Johnson c.f.a.johnson-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Fri Oct 8 22:48:20 UTC 2004


On Fri, 8 Oct 2004, William O'Higgins wrote:

> What I want to do is resize all of the JPGs in a long and ramified
> directory tree.  I figured something like:
>
> find . -name *.jpg
>
> in the top of the tree would do the trick for hitting all of the jpgs,
> but I don't know how to take the output of the above and have it do
> this:
>
> convert $FILENAME -resize 425 $FILENAME
>
> Basically, I don't know bash very well and need help with the syntax.

      So long as there are no filenames containing newlines:

find . -type f -name "*,jpg" |
  while IFS= read -r FILENAME
  do
     convert "$FILENAME" -resize 425 "$FILENAME"
  done

-- 
 	Chris F.A. Johnson                      http://cfaj.freeshell.org
 	=================================================================
                 Everything in moderation -- including moderation
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list