Skip to content

Instantly share code, notes, and snippets.

@ruslanoid
Created December 13, 2012 11:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruslanoid/4275837 to your computer and use it in GitHub Desktop.
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
#!/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
@SreeniY
Copy link

SreeniY commented May 23, 2018

Replacing '00-Playlist.m3u' with "$DIR".m3u would create the play list name using its directory name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment