On Tue, Aug 07, 2007 at 04:23:28PM -0700, David Brodbeck wrote: > > On Aug 7, 2007, at 4:04 PM, Andrew Sackville-West wrote: >> oh. I see. That is the right one. but, doesn't really work if you need >> to recurse into stuff does it, which was my problem with that find in >> the previous post. > > To do this with find, I'd try something like this: > > find . -name "*.wav" -exec lame -h -b 160 \{\} \{\}.mp3 \;
I do this one frequently to tar up small video files from a surveillance system find ./cam{1,2} -daystart -mtime +3 -exec tar -xzf '{}' + & and its all over but for the processing. > > It's possible spaces will bite you here, too ... If you actually attempt > this on filenames with spaces, test it first and see if you need to add > another level of quoting. its inevitable that these sorts of tasks have to be done on exactly the kinds of files systems that have space: music folders or some such... Note that you have to escape the curly brackets > and the semicolon so find sees them, instead of bash trying to interpret > them. Find's syntax for the "exec" action is kind of awkward-looking, but > this can be an extremely useful tool. For example, I once had to > decompress a bunch of gzipped files in a directory tree, so I did something > like this: > > find . -name "*.gz" -exec gunzip \{\} \; > > Note that find -exec can also do a lot of damage in a hurry. If you're > doing anything remotely destructive, you might want to substitute "echo > \{\}" for your command the first time you run it, just to make sure find is > only finding the stuff you want it to! Also, before you start thinking of > doing anything resembling "-exec rm" note that find has a built-in ability > to delete files. hmm... i'll look into that rm feature, but yes I routinely use -exec echo '{}' first... Regardless, its powerful and fun and once you've learned it, its incredibly efficient. my wife gets frustrated watching over my shoulder as I usually have to take a few cracks at it before I get it right. She says something about how she could be done already using the mouse and then I change from my sample tree to the real one and process several hundred files in about 20 keystrokes... then I get to be smug. :) A
signature.asc
Description: Digital signature