Post Reply 
Playlist / Direcotry slashes
18-05-2013, 22:52 (This post was last modified: 18-05-2013 23:00 by Peter@57m.)
Post: #5
RE: Playlist / Direcotry slashes
Had a play with Swiss File Knife and got it working but it made me think I should really tackle the problem at source.
I use MediaMonkey to create Playlists and there was an existing script to export all Playlists.
This one uses the windows assigned drive letter and the windows \ instead of the unix /.
So I have now created a new script to export all playlists which uses the unix / and does not use the windows drive letter. As long as you save them in the root directory specified for MiminServer they work fine.

script: the filename is ExportM3Uq.vbs in directory c:\program files\mediamonkey\scripts

' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' This file can be replaced in one of the future versions,
' so please if you want to modify it, make a copy, do your
' modifications in that copy and change Scripts.ini file
' appropriately.
' If you do not do this, you will lose all your changes in
' this script when you install a new version of MediaMonkey
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Option Explicit ' report undefined variables, ...

' SDB variable is connected to MediaMonkey application object

' Recursively process all playlists
Sub ReadPlaylists( playlists, plst, prefix)
Dim items
Set items = plst.ChildPlaylists

If prefix<>"" Then
prefix = prefix & " - "
End If

Dim i, newplst, title
For i=0 To items.Count-1
Set newplst = items.Item(i)
title = prefix & newplst.Title
If Not playlists.exists(title) Then
playlists.Add title, newplst
End If
ReadPlaylists playlists, newplst, title
Next
End Sub

Sub ExportM3Uq
' Open inifile and get last used directory
Dim iniF
Set iniF = SDB.IniFile

' Let user select the output path
Dim path
path = iniF.StringValue( "Scripts", "LastExportM3UqDir")

path = SDB.SelectFolder( path, SDB.Localize( "Select where to export all M3U files."))

If path="" Then
Exit Sub
End If

If Right( path, 1)<>"\" Then
path = path & "\"
End If

' Write selected directory to the ini file
iniF.StringValue( "Scripts", "LastExportM3UqDir") = path
Set iniF = Nothing

' Connect to the FileSystemObject
Dim fso
Set fso = SDB.Tools.FileSystem

Dim playlists
Set playlists = CreateObject("Scripting.Dictionary")

' Use progress to notify user about the current action
Dim Progress, ExpText
Set Progress = SDB.Progress
ExpText = SDB.Localize("Exporting...")
Progress.Text = ExpText

' Prepare a list of all playlists
ReadPlaylists playlists, SDB.PlaylistByTitle( ""), ""

' Go through the list and export each playlist
Dim i, iTrck, plst, fout, plsts, titles, title, tracks, trck, pwtlen, pwrlen, pwloc, pwtrack
plsts = playlists.Items
titles = playlists.Keys
Progress.MaxValue = playlists.count
For i=0 To playlists.Count-1
Set plst = plsts(i)
Set tracks = plst.Tracks
title = Titles(i)
Progress.Text = ExpText & " (" & title & ")"
If tracks.Count>0 Then
Set fout = fso.CreateTextFile( path & fso.CorrectFilename(title) & ".m3u", True)
fout.WriteLine "#EXTM3U"
For iTrck=0 To tracks.Count-1
Set trck = tracks.Item(iTrck)
pwtlen = len(trck.Path)
pwrlen = pwtlen-8
pwloc = right(trck.Path,pwrlen)
pwtrack = replace(pwloc,"\","/")
fout.WriteLine pwtrack
Next
fout.Close
End If
Progress.Value = i+1
Next
End Sub

You also need to add the script to the scipts.ini file, my script.ini file contains

[Statistics]
FileName=Stats.vbs
ProcName=ShowStats
Order=1
DisplayName=&Statistics
Description=Library Statistics Report
Language=VBScript
ScriptType=1

[ExportHTML]
FileName=Export.vbs
ProcName=ExportHTML
Order=2
DisplayName=File List (&HTML)
Description=Exports list of selected files to a .htm file
Language=VBScript
ScriptType=1

[ExportXML]
FileName=Export.vbs
ProcName=ExportXML
Order=3
DisplayName=File List (&XML)
Description=Exports list of selected files to an .xml file
Language=VBScript
ScriptType=1

[ExportCSV]
FileName=Export.vbs
ProcName=ExportCSV
Order=4
DisplayName=File List (CS&V)
Description=Exports list of selected files to a .csv file
Language=VBScript
ScriptType=1

[ExportXLS]
FileName=Export.vbs
ProcName=ExportXLS
Order=5
DisplayName=File List (&Excel)
Description=Exports list of selected files to a .xls file
Language=VBScript
ScriptType=1

[AutoIncTrackN]
FileName=AutoIncTrackN.vbs
ProcName=AutoIncTrackNumbers
Order=10
DisplayName=Auto-&increment Track #s...
Description=Sequentially numbers files
Language=VBScript
ScriptType=0

[SwapArtistTitle]
FileName=SwapArtistTitle.vbs
ProcName=SwapArtistTitle
Order=20
DisplayName=&Swap Artist and Title
Description=Swaps Artist and Title fields
Language=VBScript
ScriptType=0

[Case]
FileName=Case.vbs
ProcName=TitleCase
Order=30
DisplayName=Case Checker...
Description=Checks for correct capitalization
Language=VBScript
ScriptType=0

[ExportM3Us]
FileName=ExportM3Us.vbs
ProcName=ExportM3Us
Order=40
DisplayName=Export all Playlists...
Description=Exports all Playlists to .m3u
Language=VBScript
ScriptType=0

[ExportM3Uq]
FileName=ExportM3Uq.vbs
ProcName=ExportM3Uq
Order=41
DisplayName=Exp Playlists for MinimServer
Description=Exports all Playlists to .m3u for MinimServer
Language=VBScript
ScriptType=0


[ExportOPML]
FileName=ExportOPML.vbs
ProcName=ExportOPML
Order=50
DisplayName=Export subscribed Podcasts...
Description=Exports subscribed Podcasts to .opml file
Language=VBScript
ScriptType=0


Regards, Peter

Peter
________________________________________________________
Linn Klimax DSM O&U & Solos, Wilson Benesch ACT C60s & Torus
Linn Selekt Edition DSM Organik, Wilson Benesch P1.0
Linn Klimax Renew DSM, Chord Mezzo 75, ProAc 1SCs
QNAP 559 ProII, Melco N1ZH, MinimServer, Linn, Lumin & Kazoo
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Playlist / Direcotry slashes - KoS - 17-05-2013, 15:18
RE: Playlist / Direcotry slashes - Peter@57m - 18-05-2013 22:52

Forum Jump:


User(s) browsing this thread: 1 Guest(s)