I’ve been looking into converting a bunch of OGG files to MP3 files for a friend using BASH. As the files are organised in a directory structure, I need to traverse the directory structure, and run lame against each file to convert it. Having a look around for BASH scripts to traverse a directory structure, I found someone with a similar problem who solved it using the “find” command. I’ve taken their solution and added filtering by file extension. This solution traverses a directory structure, filters the results using a regular expression, and then executes a command against each of the filtered results. In general the command works something like this:
find /home/music -iregex ^.*\\.ogg$ -exec mysweetcommand '{}' \;
Continue reading →
Execute Command on All Files in Directory Structure by Extension
December 29th, 2008 — Nerdy Stuff