8.02.2004

Bash mp3 testing script

Say you have a directory with 100 mp3s. You want to listen to them and delete the ones you don't like. Now it's possible with the Super Bash-amatic '76!

Run this script and it plays all the songs in the directory and after each one it stops and asks if you want to keep or delete it. Just hit "d" for delete, anything else for keep. It looks like this (note, I deleted the first two, kept the third):

# ./test
Playing Artist One - Crappy Song.mp3
Type d to delete this song, anything else to keep it
Deleted Artist One - Crappy Song.mp3
-----------------------------
Playing Artist Two - Dumb Song.mp3
Type d to delete this song, anything else to keep it
Deleted Artist Two - Dumb Song.mp3
-----------------------------
Playing Cool Artist - Good Song.mp3
Type d to delete this song, anything else to keep it
Kept Cool Artist - Good Song.mp3
-----------------------------
#


Yes it's just that simple!

Notes: Since this uses mplayer to play the mp3s you don't have to listen to the entire thing. Using the right and left arrows will fast forward and reverse the song by 10 seconds. Up and down fast forward and reverse 60 seconds. Pressing "Enter" makes mplayer end the song and in this script brings up the option delete or not.

I used "d" for delete but if you want to use something other than d to delete the songs, simply change the d to something else in these two lines:

echo Type "d" to delete this song
if [ "$YorN" = "d" ]; then

#! /bin/sh
for filename in *.mp3
do
mplayer "$filename" 2> /dev/null | grep -i playing
echo Type "d" to delete this song, anything else to keep it
read -n 1 -s YorN
if [ "$YorN" = "d" ]; then
rm "$filename"; echo Deleted $filename
echo -----------------------------
else
echo Kept $filename
echo -----------------------------
fi
done



<< Home

This page is powered by Blogger. Isn't yours?