Question: Do you want to prompt the user to choose a single file, multiple files, or a folder of files?
I'm envisioning selection of a single file. I suppose it would be nice to allow multiple files but I don't think that is necessary (and that would complicate the processing code a bit). I don't se any need to allow a folder of files to be selected.
What I do envision as necessary is that the selection process would start at the "My Computer" level with the user expanding levels downward until the file is found. I don't want to make any assumptions about the path to the file.
... I don't know if MediaMonkey forces absolute paths, or can be made to work with relative ones. As I now see that the m3u files are plaintext, then editing won't be that tricky - but still a lot of work every time an update is required. I shall bow out to Les.
MediaMonkey allows relative paths, but that works only if the library and playlist file have the same relative path. In my case they will always be on different drives. I assume that is the way relative paths are expanded - the absolute path is created based on the absolute path of the file containing the relative path (or something like that).
Could you get all your users to give the same disk label to their USBs containing their portable MediaMonkey?
I could because I supply the USB drives, but I have enough trouble keeping track of the flash drives when I'm updating them that I'd prefer to keep different names on the drives. The drive labels do all start with the same characters - "MM SBD #". (My maintenance scripts check for one and only one drive with that string in the label.)
But my primary "maintenance" copy of the installation is on an internal drive on one of my computers. I would prefer that this new process to work there, too (without my having to hardcode in a test for that copy).
That very well may be the script I cannibalized to get my
Code:
Set LabelMask=SBD MM #
Set Drive=
Set Extra=
for /f %%D in ('wmic volume get DriveLetter^, Label ^| find /I "%LabelMask%"') Do (
if defined Drive set Extra=%%D
if not defined Drive set Drive=%%D
If I have understood your posts correctly,
- there is one master copy of the playlist
- everybody has a playlist in the same 'relative path' in their USBs.
So your task is simply to copy a file from one location to a corresponding location in a different drive letter e.g.
From
F:\folder1\Folder2\Folder3\CurrentPlaylist.msu
to
G:\folder1\Folder2\Folder3\CurrentPlaylist.msu
where G is unknown,
and then carry out the same substitution of G:\ throughout the playlist file once it's in place.
I don't know if the details matters, but no, that's not quite right. MediaMonkey has its own internal playlist format that resides in an SQLite database. The M3U playlists are needed only for getting a playlist out of or into MediaMonkey.
In our folkdance group, each week someone creates a new playlist. Some people create the list at out folkdance meetings. Others want to create it ahead of time and ask to take home one of our flash drives to create a playlist within MediaMonkey. This complicates keeping the flash drives in sync because we have multiple copies out sometimes for multiple weeks.
It would be much simpler (for me) if these people could create M3U playlists outside of MediaMonkey, or from a MediaMonkey that is not necessarily in sync with the others, bring their M3U playlist to the folkdance meeting, and load it into the "production" MediaMonky. These playlists will certainly have different paths than production MediaMonkey, but as long as they will refer to some copy of our library so will have easily convertible paths.
- - - Updated - - -
Well, I've got everything working except the file selection dialog. I've found lots of folder selection vbs examples and a number of questions questions about file selection, but no successful examples. The vbs function BrowseForFolder even has a "include files" option, and when specified, files are displayed, but it gives an error if a file is selected. (It works fine if a folder is selected). There are a number of reports of this on the web so I know it's not just me. There are no reports of success (that I've found) with Win10 but it apparently worked in Win7 and 8.1.
If anybody knows how to display a file selection dialog, please let me know. It obviously works in File Explorer.
If anybody cares, here's my script so far (with the file selection result overridden with a hard coded path so the script will run.
Code:
Option Explicit
dim filesys, pathname, infile, outfile
' Request the input M3U file name
infile = SelectFile( "" )
WScript.Echo "Selected File: """ & infile & """"
infile = "D:\Temp\Playlist\Test playlist.m3u"
' Determine the path of the grandparent folder of this script.
' That folder will also contain the SBD Library and the MediaMonkey folder.
Set filesys = CreateObject("Scripting.FileSystemObject")
pathname = filesys.GetParentFolderName(filesys.GetParentFolderName(WScript.ScriptFullName))
' Point to the output file.
outfile = pathname & "\MediaMonkey\Temp\Playlist.m3u"
' Open the input and output files. If the output file already exists it will be overwritten.
dim intf, outtf, infs, outfs
Set infs = CreateObject("Scripting.FileSystemObject")
Set intf = infs.OpenTextFile(Infile, 1)
Set outfs = CreateObject("Scripting.FileSystemObject")
Set outtf = outfs.CreateTextFile(Outfile, True)
' Read a playlist record from the input file.
' Modify the record to use the path to the local copy of the music library and write the record.
' Close both files when done.
Dim InLine, OutLine
Dim intLineCounter
intLineCounter = 0
Do Until intf.AtEndOfStream
InLine = intf.ReadLine
Outline = Pathname & Mid(Inline,InStr(Inline,"\FDMusic"))
outtf.WriteLine(OutLine)
intLineCounter = intLineCounter + 1
Loop
outtf.Close() ' Close output file
intf.Close() ' Close input file