Created
March 3, 2013 10:43
-
-
Save jkent/5075614 to your computer and use it in GitHub Desktop.
bash m3u playlist generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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