PaulSadowski.com 

PaulSadowski.com
Simple ASX Play List Generator
This script generates a simple ASX play list for Windows® Media Player. It will not run on Windows® 9.x or Windows® ME. It is designed for playing files off your local computer or LAN, not from a web server.

The output is sent to the Standard Output and should be redirected to a file.

The scripts take one or more arguments. The first argument may be /s (Case Insensitive) if you want all the sub-directories of the specified path(s) included. The remaining arguments are the paths and file specification of the files to be included in the play list. These arguments can be a folder name like "C:My Music" which will include all the files in that folder; a specific file such as d:\MP3s\Randi.mp3; or a path and file specification using wildcards such as F:\Movies\*.mpg

Sample usage:
MakeASX "F:\Movies\Xmas Party.avi" "F:\Movies\New Years Party.avi" > Holiday.asx
MakeASX "C:\My Music\MP3s\Cat Stevens*.mp3" > CatStevens.asx 
MakeASX /s "c:\My Music\Jazz\Modern\*.wma" > ModJazz.asx

You can then load the ASX file in WMP or click on it in Explorer to play the list.

This script used without the /s switch to do a recursive list will place the paths of the files in the current directory. Therefore, you should either CD to the directory in question when running the script or use a method like this to get the proper paths in the ASX file without using the /s switch.

for %c in ("E:\Cat_Stevens" "E:\Harry Chapin") do @pushd %c & c:\bin\makeasx %c\*.wma > c:\temp\%~nc.asx & popd

(That should all be on one line!)

Notice the directory names, you can use one or many, go into the setlist (between the parenthesis) and are double quoted, always. The full path to the MakeASX.cmd file and to the output directory is also required.

That will put the output into directoryname.asx In this case it would be:
C:\temp\Cat_Stevens.asx
C:\Temp\Harry Chapin.asx

You can then rename the ASX files to whatever you like.

::MakeASX.cmd
@echo off & setlocal enableextensions
if .%1.==.. Goto Usage
set DIRCMD=
echo.^<ASX VERSION="3.0"^>
for /f "tokens=*" %%c in ('dir /b /a-d-h %*') do (
 echo  ^<ENTRY^>
 echo    ^<REF HREF="%%~fc" /^>
 echo  ^</ENTRY^>
)
echo.^</ASX^>
Goto :EOF
:Usage
echo Usage: %~n0 [/s] FileSpec FileSpec FileSpec ...
echo Where /s means process all subdirectories
echo Example:
echo %~n0 /s "C:\my Music\*.mp3" d:\videos
echo.
:EOF

© 2004 by Paul R. Sadowski 
All Rights Reserved. Used By Permission.
Comments to: Scripting