I am attempting to unify my playlists so that I can maintain them on one system (madsonic) and have them automatically transformed and maintained on my other systems (primarily Sonos, maybe XBMC and Plex). To accomplish this I wanted to create a script that will transform my playlists and automatically save them in another folder, after I have created them in madsonic.
/mnt/music/playlists/madsonic/ <--I want to auto-export all playlists created to this folder (every 5 minutes should be fine). I have the option set in Madsonic > Settings > General under export playlists to, but the playlists don't get exported unless use Export Playlists under Settings > Playlist. Any way to schedule this to run automatically? Also the playlists are in .m3u8 format. It appears that I can simply rename them to .m3u with no problems so I was just planning to do that with the script below.
Then (using cron) run this script every 5 minutes or so. The purpose here is to change (for all .m3u8 files in /mnt/music/playlists/madsonic) the paths from /mnt to //10.0.10.91 and save the new (.m3u) file to /mnt/music2. I need some help getting this finished - the sed rename part works when I run it for one file, but I am not sure how to make it run for each .m3u* file in a given directory and save them with the same names in another directory:
- Code: Select all
for *.m3u8 in $MADSONICPLAYLISTS
sed -n '
gpw '/mnt/music2/$MADSONICPLAYLISTS.m3u' $MADSONICPLAYLISTS.m3u
Once the file is transformed and saved to /mnt/music2, Sonos will automatically pick it up from here. If the playlist already exists in /mnt/music2, I would like the script to overwrite the old version with the new. This will be one way sync only.
Madsonic 5.0.3830 running on dedicated Debain 7.3 vm.
Thanks in advance for any assistance!