#!/bin/sh
# Convert Stepmania MP3 Song packages to OGG format for use on Maemo
# by Thomas Perl <thpinfo.com/about>; 2010-03-23
# Updated: 2010-05-04 (Only handle files)

for dir in *; do
    if [ ! -d "$dir" ]; then
        echo "Skipping non-dir: $dir"
        continue
    fi
    cd "$dir"

    # Convert MP3 files to OGG
    for file in *.mp3; do
        mpg123 -w tmp.wav "$file"
        oggenc -q 0.5 tmp.wav -o "`basename "$file" .mp3`.ogg" && rm -f "$file"
        rm -f tmp.wav
    done

    # Remove background animations (if any)
    rm -f *.avi

    # Update stepfiles to use OGG files instead of MP3
    sed -i -e 's/.mp3/.ogg/g' *.sm

    cd ..
done


