My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# This script converts all MP3s in the directory tree routed 'here'
# to OGG vorbis format at 192kbps. It won't delete the original MP3s,
# so that will have to be done manually after it has finished. The
# script will generate its own list of files to process so that it can
# be resumed at any later point if it is stopped.

# Generate a list of all MP3s in the directory tree, or use an already
# existing one (when resuming).
if [ ! -f "list.txt" ] ; then
find . -iname "*.mp3" > list.txt
fi

# Iterate over every file in the list, converting it to OGG
# This requires first decoding the MP3 with mpg321 into a WAV
# file, and then encoding to OGG (at 192 kbps) with oggenc.
# Finally, when the conversion is done, remove the file from the list.
cat list.txt | while read file ; do
tempfile=`echo $file | sed 's/mp3/wav/'` ;
oggfile=`echo $file | sed 's/mp3/ogg/'` ;
mpg321 "$file" -w "$tempfile" ;
oggenc "$tempfile" -o "$oggfile" -q 6 ;
rm "$tempfile" ;
tail --lines=+2 list.txt > list.tmp ;
mv list.tmp list.txt ;
done

# Clean up
if [ -f "list.temp" ] ; then rm list.temp ; fi
if [ -f "list.txt" ] ; then
if [ ! -s "list.txt" ] ; then rm list.txt ; fi
fi

echo "ALL DONE!"
Show details Hide details

Change log

r22 by meithan on Sep 18, 2009   Diff
Added two small scripts not related to the
project since Facebook and Blogger suck at
posting code (i.e. they can't) ><
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1228 bytes, 34 lines

File properties

svn:executable
*
Hosted by Google Code