[Script] Convert iTunes playlists to Madsonic

Scripts for Madsonic
gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

[Script] Convert iTunes playlists to Madsonic

Unread post by gurutech »

I created a small script for myself that will convert my existing iTunes playlists on my Windows machine to the proper format for my Linux-based Madsonic installation.

Step 1: Export your iTunes playlists (even "Genius" lists will work with this!) to a folder on your Windows computer
Step 2: Run the "fixlist.cmd" file from within the folder where you exported your playlists. (See below for code)
Step 3: Import your playlists into Madsonic!

Below is the script for what is needed to do the above. There are two files you need to create. One is "Fixlist.Cmd", and the other is "Fixlist.vbs". The CMD file will "call" the VBS file. You will only need to make changes to the CMD file, based on your storage locations.

FIXLIST.CMD

Code: Select all

@echo off
REM  ** Change to the drive where your media is **
X:
REM ** Change to folder on drive above where media is stored **
cd \allshared\media\playlists
REM ** The Next two lines call the VBS file.  
REM ** Line 1 converts the data folders from the Windows path to the Linux path
REM ** Line 2 converts any remaining \ into / (If you are not using Linux, then REM this line out!)
REM ** Note:  To view the full path, open a playlist in Notepad, and you can copy/paste here
for %%A in ("*.m3u8") DO cscript //nologo fixlist.vbs "%%A" "X:\path\from\playlist\file" "\linux\path\to\media"
for %%A in ("*.m3u8") DO cscript //nologo fixlist.vbs "%%A" "\" "/"
FIXLIST.VBS

Code: Select all

Option Explicit
Dim fso,strFilename,strSearch,strReplace,objFile,oldContent,newContent
 
strFilename=WScript.Arguments.Item(0)
strSearch=WScript.Arguments.Item(1)
strReplace=WScript.Arguments.Item(2)
 
'Does file exist?
Set fso=CreateObject("Scripting.FileSystemObject")
if fso.FileExists(strFilename)=false then
   wscript.echo "file not found!"
   wscript.Quit
end if
 
'Read file
set objFile=fso.OpenTextFile(strFilename,1)
oldContent=objFile.ReadAll
 
'Write file
newContent=replace(oldContent,strSearch,strReplace,1,-1,0)
set objFile=fso.OpenTextFile(strFilename,2)
objFile.Write newContent
objFile.Close 
These users thanked the author gurutech for the post (total 2):
MadsonicAndrusa
Rating: 15.38%
Post Reply