Re: OT: running a command on many files in many subdirectories
On Wed 29 Jan 2003 10:27:22 +(+), Clive Standbridge wrote: I think you would want to round up nnumber to avoid one processor running two xargs processes: Sorry, that wasn't quite what I meant to say. I'll try again: ... to avoid xargs running two mogrify processes on one processor. I hope that that's clearer. -- Cheers, Clive -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: OT: running a command on many files in many subdirectories
Well, I wish I had gone and goofed off for the rest of the evening then come in and used one of these 2-3 line solutions this morning. Still, I learned some things reading them and will use them and the tldp reference for future scripting. Thank you, Levi -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
OT: running a command on many files in many subdirectories
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. If this is difficult I could copy all the jpg files into a single directory first with only a little bit of tedium. Thank you, Levi -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
OT: running a command on many files in many subdirectories
Never mind, I finished the task. I just first copied all the files into one directory using: find . -name *.jpg -print | xargs -i cp \{\} all/ Then wrote (modified, actually) a shell script to run imageinfo on a bunch of files with a different output file each time: #!/bin/bash # run imageinfo on many files ARGS=2 E_BADARGS=65 if [ $# -ne $ARGS ] then echo Usage: `basename $0` (extension of input files) (extension of output files) exit $E_BADARGS fi { for filename in *.$1 do java ImageInfo $filename ${filename%.$1}.$2 done } exit 0 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
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/ msg27017/pgp0.pgp Description: PGP signature
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 [[EMAIL PROTECTED]] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: OT: running a command on many files in many subdirectories
On Tue 28 Jan 2003 17:56:51 +(-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. Try this: for f in */*.jpg ;do java ImageInfo $f commondir/`basename $f .jpg`.txt ;done If there are too many files for the command line then replace for f in */*.jpg with find . -maxdepth 2 -name \*.jpg | while read f If this is difficult I could copy all the jpg files into a single directory first with only a little bit of tedium. No need for that. I hope this helps. -- Cheers, Clive -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: OT: running a command on many files in many subdirectories
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. If this is difficult I could copy all the jpg files into a single directory first with only a little bit of tedium. Thank you, Levi for i in `find . -name *.jpg`; do java ImageInfo $i `echo $i | sed -e 's~^.*/~commondir/~' -e 's/jpg$/txt/'`; done all on one line. You probably want to look over http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html and/or http://www.tldp.org/LDP/abs/html/ for guides on how to write simple scripts. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: OT: running a command on many files in many subdirectories
On Tue, 2003-01-28 at 23:56, 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, Here is something I wrote to do batch Imagemagick conversion on a whole tree of image while taking advantage of multiple processors if available. Maybe some of the techniques used could be transposed in your context. files=`find . -name '*.tif' -print | wc -l | tail -c 2 | head -c 1` cpu=`grep processor /proc/cpuinfo | wc -l | tail -c 2 | head -c 1` nnumber=`expr $files / $cpu` find . -name '*.tif' -print | sed -e 's/ /\\ /g' | sed -e 's/(/\\(/g' | sed -e 's/)/\\)/g' | xargs -P $cpu -n $nnumber mogrify -format png signature.asc Description: This is a digitally signed message part