Oggrecode Script

This script recodes an entire directory to a new quality of vorbis. It could easily be modified to transcode to ogg as well.


#!/bin/bash
# (c) 2008 linux-tipps.blogspot.com
# published under the GNU GPL v 3.0

echo OggRecode v 0.01
echo

OUTDIR="$1-recode_q$2"
ME=`basename $0`

if [ $# != 2 ]; then
echo \#$ME \"directory\" quality
echo I need two parameters: a directory and a quality setting,
echo but you gave me $# parameter\(s\): \($ME $*\)
echo
exit 1;
fi

if [ ! -d "$1" ]; then
echo Parameter \"$1\" is not a directory!
# direct file handling here
exit 2;
fi

if [ -e "$OUTDIR" ]; then
echo A file or directory with the name \"$OUTDIR\" already exists.
exit 3;
fi

if [ ! -f "$1"/*.ogg ]; then
echo No vorbis files found in directory \"$1\":
echo Directory listing:
ls "$1";
echo ---
echo
exit 4
fi

mkdir "$OUTDIR"
cd "$1"

for i in *.ogg; do
TO="`basename $i`"
TO="$i"
cd ..
cd "$OUTDIR"
echo Recoding \"$i\" ...
echo oggdec -Q -o - ../"$1"/"$i" \| oggenc -q "$2" -o "$TO" -
oggdec -Q -o - ../"$1"/"$i" | oggenc -q "$2" -o "$TO" -
echo ... finished recoding \"$i\".;
echo
done

cd ..
echo Finished encoding


No comments:

Post a Comment

I appreciate comments. And I do read them.