Here's a Random/Shuffle Playlist Creation Program
This thread evolved from a previous one on the subject of random/shuffle play. However, this takes the topic in a new direction, namely that of an actual solution. Some will find it inferior to what they hope will someday be included in the firmware of the Patriot Box Office, but it does offer a few advantages that firmware cannot match. In any case, you're welcome to use my program.
I wrote this in Visual Basic Scripting language, so you'll be able to read it yourself and verify that it contains no malicious content. You will also be able to make minor changes or even major additions to the program without access to any compiler or other programs.
The solution I devised is a simple randomized playlist creator that takes into account the special requirements of a network media player like the Patriot Box Office. Once you do a little minor setup, this program can be invoked from your Windows Explorer context menu, specifically as a "Send To" target. There are only two types of objects it will perform an operation with (ignoring all others):
A) With an existing playlist file, it will simply read the playlist into memory, shuffle the order of the songs, and then overwrite the original playlist file, retaining all the original contents. There is a dialog to confirm the operation.
B) With any folder object (selected via Explorer), the playlist maker will find all the music files it contains and optionally recurse all subdirectories and find any music within that entire structure. Then it will randomize this list and write a playlist file in the root of the folder that was selected in Explorer. The playlist entries do not use absolute paths, but rather just the path relative to the location of the playlist file itself. Thus, as long as the playlist file isn't moved to another folder, it will play just fine in the Patriot Box Office over a network connection.
Here is a link to the text file for browser viewing:
Download the zipped .VBS file with this link:
Here's how to set this program up for use in Windows Explorer:
1) Unzip and move the script file to the location where you want it to reside.
2) Create a shortcut to the script file. When naming the shortcut, remember that this is the label that will appear on the "Send To" submenu. If you like, you can even assign a special icon for the shortcut that will replace the standard drab VBS icon.
3) Locate your user "SendTo" folder and move the shortcut file to this folder.
In Windows XP, it is "C:\Documents and Settings\(user name)\SendTo."
Windows 7 uses "C:\Users\(user name)\AppData\Roaming\Microsoft\Windows\SendTo."
That's it! Now you can right-click on any folder or existing playlist in Explorer that is within the network share structure accessible to Patriot Box Office, mouse to the "Send To" menu item and send it to "Randomized Playlist Maker," and the appropriate action will be performed. I included a line in the script that opens the finished playlist in NotePad for your inspection, but you may want to disable that command after using it a few times. Maybe this will help a few people get slightly better use from the Patriot Box Office. I know I'm rather fond of mine.
New feature added 4/20/2010: "Silent Mode" for scripting and other forms of automated execution, so dialogs can be suppressed for an automated context without altering the way the program behaves when invoked manually in Windows Explorer. For an automated context, a shortcut can be created and added to your Windows startup folder that will reshuffle your favorite playlist every time you reboot. Or this can be done on a more regular or frequent basis by creating a Windows Scheduled Task. In most usage, I think you can safely omit the reference to "Wscript.exe" below, but it seems to be necessary with the Windows Task Scheduler, so I've included it.
Here's the command line syntax for scripted or shortcut execution (including Silent Mode switch):
Wscript.exe Randomized_Playlist_Maker.vbs [/s [/nr]] (target)
Wscript.exe "C:\Program Files\_MiscScripts\Randomized_Playlist_Maker.vbs" /s "D:\Music\_MyPlayList.m3u"
(this command shuffles the lines in "_MyPlayList.m3u" while displaying no dialogs or finished playlist)
Wscript.exe "C:\Program Files\_MiscScripts\Randomized_Playlist_Maker.vbs" /s /nr "D:\Music"
(generates a randomized playlist of the "D:\Music" folder, and the optional "/nr" switch suppresses recursion)
New feature added 5/1/2010: Playlist Naming Dialog, which not only allows you to give the playlist file a custom name at the time it is compiled, but it allows you to specify a path further upstream (toward the root) where the playlist file will be created. The significance of this is that when you create the playlist in another directory, the pathnames of the entries inside the playlist need to reflect the correct relative paths to the files from the location of the playlist, which isn't the case if you simply move the playlist file. Also, the default name for the playlist file is now based on the name of the target folder from which the playlist is compiled (this affects silent mode as well). This should make it easier to create multiple playlists without name collisions that might result in one playlist overwriting another.
Minor bug-fix added on 5/10/2010: When creating a new playlist using command-line syntax (such as from a batch file), text case (capitalization) in the specified path had to match Windows' folder names exactly, or else the pathnames in the playlist would be incorrect. Sloppiness is now tolerated
Last edited by GaryM; 05-11-2010 at 01:36 AM.
Reason: another script update
very fine work GaryM.
Tons of thanks,
An equal tonnage of "you're welcome" back at ya, aasoror
I use Sneakernet with USB drives, so I'm not sure I will use this, but I do appreciate you taking the time to provide a workaround for this major problem with the PBO. Thanks.
thanks alot garyM
Thanks for your work GaryM, works like a charm!
Excellent work GaryM, thanks for passing it along!
This script is brilliant!
I do have a question... Would it be possible to run a similar script that would target a selected folder/playlist during computer bootup (i.e., vbs shortcut in startup folder)? I have zero knowledge of vbs code, but with some tinkering I disable the yes/no prompts for subdirectories and m3u rewrite (since my answer is always 'yes'). It would be nice to automatically have a fresh playlist mix with every startup. Although the 5 seconds it takes to do it manually will not kill me.
Just to elaborate:
Here's my slightly tweaked version (attached zip), with no txt popup, and minus the prompts for subdirectories and playlist reorder/rewrite. Could a similar script be used to automatically target a specified folder on bootup, instead of using Send To?
I'm not sure if I mangled the code here so someone might want to verify that it is clean. I does work well for me.
Last edited by si1verfish; 04-25-2010 at 06:56 AM.
Thanks for your comments and interest, Si1verfish. I like your idea of regular, automatic reshuffling of the playlist. By golly, it's very doable, and so I've even added an optional "silent mode" command line switch so the program can be run without any dialogs or interaction, without the necessity of making the script modifications you made (well done, btw). There's also a special syntax that's required when running this script as a Windows Scheduled Task. I've edited my original post at the top to include the additional info, and the downloadable file at my original link is the new version. To make a shortcut that will invoke an automated shuffle, just open notepad and construct a command line in the form of one of my examples, and then copy and paste that text as the "location of the item" in a new shortcut. Then give the shortcut a name and you're ready to drag it to the StartUp folder of the Start Menu. It should execute at boot time shortly after you log in.
Originally Posted by si1verfish
However, those mods you made are still necessary if you never want to see any dialogs when invoked as a "Send To" item, but you shouldn't have any trouble blocking those again (or just keeping your version). Also don't forget that including additional music file extensions to the filter is easy, just by editing the function at the end of the program. Let the good times roll