On 2004-01-03 15:58:46 +0000 Syd Hancock syd@toufol.com wrote:
Basically all I want to do is to feed all the files from a directory one by one into an application - i.e. using lame to encode wav files to mp3.
Most shells have some way to do this. For bash: for a in *.wav ; do lamecommand "$a" ; done or for rc: for (a in *.wav) { lamecommand $a }
In both, the command is repeated many times with $a being each file name in turn. It is put in ""s for bash to stop filenames with spaces screwing it up, as bash replaces $a and then scans the command. rc doesn't have that problem ;-)
Alternatively, you can use find, which can do subdirectories by default: find . -exec lamecommand '{}' ';'
The '{}' gets replaced by the filename and ';' is the end-of-command marker. Both are single-quoted to stop the shell playing with them.
You can do this from perl, too, but that may be overkill for many instances. The above examples are untested, so test with echo and |more before use.