Created
December 13, 2012 11:23
-
-
Save ruslanoid/4275837 to your computer and use it in GitHub Desktop.
a little batch script that create an m3u playlist for each sub-directory of the given base directory that contains mp3 files, and an m3u playlist containg all the child directories in the parent directory if the tree structure actually goes that deep
This file contains 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 | |
BASEDIR=$1 | |
if [ "$BASEDIR" == "" ]; then | |
echo You must specify a base directory | |
exit 1 | |
fi | |
cd $BASEDIR | |
BASEDIR=`pwd` | |
# Remove existing playlists | |
find . -name '*.m3u'|sed -e "s/^/\"/"|sed -e "s/$/\"/"|xargs rm -f | |
# Remove funky Mandrake backup files | |
# find . -name '*~'|sed -e "s/^/\"/"|sed -e "s/$/\"/"|xargs rm -f | |
find . -type d |sort| while read -r DIR; do | |
cd "$BASEDIR/$DIR" | |
find . -type f |grep -v m3u | grep -i mp3 |sort> '00-Playlist.m3u' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replacing '00-Playlist.m3u' with "$DIR".m3u would create the play list name using its directory name.