[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: running a command on many files in many subdirectories



On Tue, Jan 28, 2003 at 05:56:51PM -0500, Levi Waldron wrote:
| I'm sure this is simple, but maybe someone here can help me do it in a few 
| minutes instead of hours.  I have a bunch of files in a bunch of 
| directories, and I want to run the same command on each of them.  For each 
| input file, the output file should have the same name except ending in .txt, 
| and the output files should be put a common directory.  ie,
| 
| java ImageInfo dir1/pic1.jpg > commondir/pic1.txt

Try this (works for any level of directory nesting) :

for F in `find . -name \*.jpg` ; do
    java ImageInfo $F > commondir/`basename $F`.txt ;
done

(it can be typed all on one line)

HTH,
-D

-- 
If you want to know what God thinks about money,
just look at the people He gives it to.
    -- Old Irish Saying
 
http://dman.ddts.net/~dman/

Attachment: pgpXwdovvA6gZ.pgp
Description: PGP signature


Reply to: