[Gllug] Maintaining music libraries in various formats

Richard Jones rich at annexia.org
Thu Aug 20 14:15:24 UTC 2009


On Thu, Aug 20, 2009 at 02:39:48PM +0100, Jon Dye wrote:
> I had an idea to somehow use SCons to "build" the mp3s/oggs from the
> flac files but that only supports requirements 1.  The other option
> was to write a custom python (or similar) script to do it.

It's a pretty simple shell script.  The core of it would be this:

(cd $musicdir && find -name '*.flac' ) | (
cd $mp3dir;
while read filename; do
  base=$(basename $filename .flac)
  dir=$(dirname	$filename)
  output="$dir/$base.mp3"
  mkdir -p $dir
  if [ ! -f $output ]; then
    $transcode $filename $output
  fi
done
)

where $musicdir is your music directory (maybe a recursive
subdirectory structure) containing *.flac files, $mp3dir is the
directory of MP3s, and $transcode should be replaced by whatever
command transcodes from flac to MP3.

Because of the subshells, you need to export musicdir and mp3dir and
any other variables you need to use inside the subshell.

Rich.

-- 
Richard Jones
Red Hat
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list