Playlist generation
Simple shell script for generateing playlists
1. Script for å lage spillelister
genplaylists.sh
This script makes a playlist in every folder recursive in the folder given as an argument. **All* filetypes are included in the list. Hvis you only want one file type added to the list then edit the laste line
find . -type f |grep -v m3u|sort> '00-Playlist.m3u'
and add -iname *.mp3
find . -type f -iname *.mp3|grep -v m3u|sort> '00-Playlist.m3u'
Example:
makeplaylists.sh.pre /pub/audio
You must make the script executable before using it:
chmod a+x myfile
2. make-ogg-playlist
!/bin/bash
#
# make-ogg-playlist v0.1 (By Sam Storie)
#
# Changelog:
# v0.1 Initial Creation
#
#
# This creates a series of XMMS playlist files
# from an ogg library that is organized like:
#
# /home/sam/music
# +- Radiohead
# +- Paranoid_Android
# | +- Track1.ogg
# | +- Track2.ogg
# +- Hail_to_the_Theif
# +- Track1.ogg
# +- Track2.ogg
#
# and creates these files:
# .../music/all.pls (all oggs)
# .../music/Radiohead.pls (from Radiohead)
# ../music/Radiohead/Paranoid_Android.pls (that album only)
# .../music/Radiohead/Hail_to_the_Theif.pls (that album only)
#
# Needs to be full path (ie, ~/music won't work)
ROOT=/home/sam/music
cd $ROOT
BuildPlaylist() {
ct=1
NUM=$(find $1 -type f -name *.ogg | wc -l | awk '{print $1}')
echo "[playlist]" > $2.pls
echo "NumberOfEntries=$NUM" >> $2.pls
for i in `find $1* -type f -name *.ogg`; do
echo "File${ct}=${ROOT}/${i}" >> $2.pls
ct=`expr $ct + 1`
done
}
# Do all the subdirectories
for j in `find * -type d -maxdepth 1`; do
BuildPlaylist $j $j
done
# Make a list for all of them
BuildPlaylist "" "all"
3. genplaylists.sh
#!/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|sort> '00-Playlist.m3u'
done