It runs on Linuxes (bourne shell) and embedded linuxes (oleg, dd-wrt etc).
Specify the full locations of your music partitions in line 3:
searchfolders="/opt/part1 /opt/part2 /opt/part3"
Then, tell it where to store the new playlists (should be a folder scanned
by TwonkyVision):
storeplayliststo=/opt/part1/_playlists_
For each music directory it finds, it will create a .m3u playlist containing the
.mp3 files found in that directory.
The playlists then should be found by Twonky on its next trip through
your data.
Warnings: Must be run from within a writeable directory (cd /tmp first).
Works only non-recursive (folders within folders are not seen).
May choke on some special characters in filenames I didn't catch yet.
Spits out all sorts of warnings (never mind).
Uses only primitive shell commands so it runs in embedded environments
(alas, no perl, no find there). Improve it if you want...!
Enjoy,
MOS
Code: Select all
# mklists.sh
#
# configure your file locations...
# separate multiple folders by blank
# omit trailing slash of all folder names!
searchfolders="/opt/part1 /opt/part2 /opt/part3"
storeplayliststo=/opt/part1/_playlists_
# collect all subfolders in a file...
if test -e ./folders.tmp; then rm folders.tmp; fi
for fn in $searchfolders
do
ls -d $fn/* >> folders.tmp
done
# replace non-filesystem characters by ?
sed -i "s/ /\?/g" folders.tmp
sed -i "s/(/\?/g" folders.tmp
sed -i "s/)/\?/g" folders.tmp
sed -i "s/&/\?/g" folders.tmp
# loop through subfolders, collect content in playlists
i=1
while [ $i -le `wc -l folders.tmp | awk '{print $1}'` ] ;
do
folder=`head -$i folders.tmp | tail -1`
i=`expr $i + 1`
ls $folder/*.mp3 > playlist.tmp
# basename reintroduces the blanks into the foldername, hence, the sed
shortfolder=`basename $folder | sed s/[^a-zA-Z0-9.-_]//g`
if test -s playlist.tmp; then mv playlist.tmp $storeplayliststo/$shortfolder.m3u; fi
done