$ man checkmp3
I have written a shell script which converts improper mp3's into proper mp3.
#!/bin/bash
## Script to fix mp3 files using checkmp3
## Checking existance of checkmp3
checkmp3=`which checkmp3`
if [[ "$checkmp3" == "" ]]
then
echo "$0: please install checkmp3."
exit
fi
if [ $# -ne 1 ]
then
echo "USAGE: $0 <mp3_file|dir_with_mp3s>"
exit
fi
dir="$1"
file=""
if [[ -d "$dir" ]]
then
echo "processing directory '$dir'"
temp_file="$dir/fixed.mp3"
for file in `find "$dir" -iname "*.mp3" | sed 's/ /\\\_/g'`
do
file=`echo "$file" | sed 's/\\\_/ /g'`
echo "processing file '$file'"
$checkmp3 -i -sf "$file" > "$temp_file"
if [ $? -ne 0 ]
then
echo "$0: error in processing file '$file'"
else
#eyeD3 "$temp_file"
#$checkmp3 "$temp_file"
mv "$temp_file" "$file"
fi
done
rm -f "$temp_file"
else
file="$dir"
echo "processing file '$dir'"
dir=`dirname "$file"`
temp_file="$dir/fixed.mp3"
echo "$temp_file"
$checkmp3 -i -sf "$file" > "$temp_file"
if [ $? -ne 0 ]
then
echo "$0: error in processing file '$file'"
else
#eyeD3 "$temp_file"
#$checkmp3 "$temp_file"
mv "$temp_file" "$file"
fi
fi
exit 0
Sample run:
$ ./fix_mp3.sh xyz.mp3
$ ./fix_mp3.sh /path/to/mp3/directory/
No comments:
Post a Comment