Background:
We have several identical copies of our music library - some on USB flash drives, some on various computer's hard drives, one copy on a NAS. The library is named FDMusic in each case, but the path to the library varies from instance to instance. We have a (portable) copy of MM paired with each library. (Each MM uses just one music library.) We want a playlist created on any of the platforms to be able to be used on any other.
There are some already written MMW4 scripts that import playlists, but that ignore everything but the lowest level part of the file name and find multiple instances of the same named files. We needed an exact match on all of the path below \FDMusic\.
So, my MMW4 script
- Asks for a playlist file name. (More about this later.)
- Determines this MediaMonkey's path to its FDMusic library. (More about this later.)
- Opens the playlist file and a temporary output file.
- Reads a playlist record.
- Changes the high level library path to the local MM's library path
- Writes the output record and loops back to process the next record.
- Closes the files.
- Invokes MM (again) with /ADD to read the temporary file.
The most general problem is that I don't know JS (but then, I didn't know VBS, either, so I suspect I can work through that.)
More specific problems:
- MMW4 has not way of prompting for a file name (rather than a directory). In fact, Windows provides few ways of doing this, but it can be done in HTA. So my MMW4 script invokes HTA which prompts for a file name and saves the result in a Windows environment variable. The script then extracts the playlist file's path from the environment variable.
I don't know if HTA can be invoked from MMW5.
I don't know if the environment variable access functionswill work in MMW5 (although I assume they do).Code: Select all
Function delENV(ENV) '* '* Del Environment Variable '* Dim objWSS Set objWSS = CreateObject("WScript.Shell") Dim objENV Set objENV = objWSS.Environment("Volatile") objENV(ENV) = "" Set objENV = Nothing objWSS.RegDelete "HKCU\Volatile Environment\" & ENV Set objWSS = Nothing End Function Function getENV(ENV) '* '* Get Environment Variable '* Dim objWSS Set objWSS = CreateObject("WScript.Shell") Dim objENV Set objENV = objWSS.Environment("Volatile") getENV = objENV(ENV) Set objENV = Nothing Set objWSS = Nothing End Function
- My MMW4 technique for determining the local MM's library path is short but (I suspect) very inefficient[
Does this work in MMW5? And is there a better way?
Code: Select all
Set TrackData = SDB.Database.QuerySongs(" ") If Not TrackData.EOF Then 'TrackData.Item is a SDBSongData Object TrackPath = TrackData.Item.Path End If
- Does MMW5 have the /ADD option?