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
>
> etc, repeated over a bunch or directories and jpg files. The subdirectories
> only go one deep.
Sounds like you want:
for x in your-list-of-files; do
java ImageInfo "$x" > commondir/"`basename \"$x\" .jpg`".txt
done
... or something similar. You could use either wildcards or 'find' for
the your-list-of-files part.
Cheers,
--
Colin Watson [cjwatson@flatline.org.uk]
Reply to: