Running a command on all file occurences in a directory tree

Sergey Kuznetsov tlug-9a/WvBvX2Qpg9hUCZPvPmw at public.gmane.org
Sat Oct 9 14:59:45 UTC 2004


Chris F.A. Johnson wrote:

> 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
>
find . -name "*.jpg" -exec convert {} -resize 425 "small-{}" \;


That is it.


All the Best!
Sergey.
--
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