Skip to content

Instantly share code, notes, and snippets.

@jkent
Created March 3, 2013 10:43
Show Gist options
  • Save jkent/5075614 to your computer and use it in GitHub Desktop.
Save jkent/5075614 to your computer and use it in GitHub Desktop.
bash m3u playlist generator
#!/bin/bash
add_song() {
file=`readlink -e "$1"`
name=`basename "$1" | sed 's/\(.flac\|\.m4a\|\.mp3\|\.ogg\|\.wma\)$//i'`
echo "#EXTINF:0,$name" >> $playlist
echo "$file" >> $playlist
}
playlist=$1
shift
echo "Gathering and sorting files..."
tmp=`mktemp`
find "$@" -type f -print | sort > $tmp
echo "Writing output file..."
echo "#EXTM3U" > $playlist
while read line
do
add_song "$line"
done < $tmp
rm $tmp
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment