Jump to content

A simple asx playlist generator script


Recommended Posts

Guest HelloDave
Posted

Here's a simple little asx playlist generator script that I hacked together. It lists all the files with a particular extension in one folder, sorts them alphabetically and writes an asx playlist for them. It isn't the finest coding you'll ever see, but it works! It's written in JScript and runs under the Windows Scripting Host, so to get it to work you need to copy the code below into notepad and save the file anywhere you like as "lister.js" (or any filename with a js extension). Include the quotes when you save from Notepad otherwise it'll add a .txt extension and the script won't run.

//Generates an asx playlist of the files of a specified type


//Written by Andy (HelloDave), Jan 2003 and posted on MoDaCo SmartPhone forums


//And it comes with no warranty whatsoever! :-)




var fso, list, files, filecount, folder, curSelFolder, mp3s, tempFile, outputFile, fileType


fso = new ActiveXObject("Scripting.FileSystemObject")


mp3s = new Array()


filecount = 1




/****************** Options Section *******************/




// Folder to read filenames from


folder = "F:My DocumentsTunes"


// Path to write finished .asx playlist to


outputFile = "F:My DocumentsTunesAll_wmas.asx"


// Filetype to list wma is audio, wmv is videos


fileType = "wma"




/******************************************************/




list = fso.CreateTextFile(outputFile)




// List all the files in the chosen folder and put them in an array


curSelFolder = fso.GetFolder(folder)


files = new Enumerator(curSelFolder.files)


for (; !files.atEnd(); files.moveNext())


	{


	// Filter out any rogue filetypes


	if (fso.GetExtensionName(files.item()) == fileType) 


  {


      // Strip the filename from the full path and put it in the array


      tempFile = new String(files.item()).toLowerCase()


      mp3s[(filecount-1)] = tempFile.substring(tempFile.lastIndexOf("")+1,tempFile.length) 


        filecount++


  }


	}




// Sort the array into alphabetical order


mp3s.sort()


filecount = 1




// Write the asx playlist


list.WriteLine("<asx version="3">")




while (filecount < mp3s.length)


{


	list.WriteLine("<entry><ref href = "" + mp3s[(filecount-1)] + ""/></entry>")


	filecount++


}


list.WriteLine("</asx>")




list.Close()

I've posted the code like this so that you can see what it does, and those people who know some JScript can confirm it's not a virus! :(

The script should run on Windows '98 and above - just double click on the filename (lister.js or whatever). To actually get it to do something useful, you need to change a few things in the options section at the top. When typing paths like C:folderfile.txt make all s into s like the original script otherwise you'll get some errors!

- Make folder = "F:My DocumentsTunes" point to where all the files you want to list are.

- Make outputFile = "F:My DocumentsTunesAll_wmas.asx" point to where you want to save the asx playlist the script writes

- Set fileType = "wma" to the filetype you're trying to list, for example "wma" for windows media audio files. At the moment the script only lists one filetype at a time, but to list everything in a folder comment out the "if (fso.GetExtensionName(files.item()) == fileType)" bit

I wrote this script because I was fed up of having all my video and audio files lumped together in a random order in Media Player and I've just got an SD card reader, so I can list the files and write the playlist direct to the memory card. If you haven't got a card reader it probably isn't that useful because you can't access the SPV via a drive letter, which is a pain!

If anyone finds this useful - let me know! I'm open to (simple :D) suggestions to improve it. For example, list more than one filetype at a time, like .mp3 and .wma

Guest spacemonkey
Posted

Check this topic

http://www.modaco.com/viewtopic.php?t=877

How about a different version of the script that will create a playlist for a single wmv file with a heap of bookmarks like in settings specify every 5 mins or something.

Only difficulty would be that you'd really need to know the total length I spose...

Guest HelloDave
Posted

Hmm, well I did have a go at that, but the problem is it involves using ActiveX objects with Windows Scripting Host and it all got a bit messy and didn't work! :cry: I might try doing a proper version in VB when I get some time - it is possible, just needs a bit of work to get it going!

Can anyone else can come up with a solution? My idea was to use a Windows Media Player object in the script to open each file and find its length (bit slow I know), which i've got working before in VB. My script opened the file ok but always reported its length as 0. I think it's because the file wasn't fully loaded before the script queried its length property, but I couldn't find a way to make it wait until it had finished loading. Probably something to do with an event, but it all got a bit messy and I left it!

Guest akarno
Posted

I have been working on a solution to this (Visual Basic). Nearly finished. I just want to package it up neatly and do some further testing. I did ask some people to test a while ago but although I sent it to a few people, I never got any feedback.

Guest adrianfox
Posted

I have knocked up a little application that generates an Asx PlaylistFile and also copies the associated tracks to a specified folder.

It won't write directly to the phone, but it can be use with an SD card in a reader that appears as a Storage Device in explorer.

It works with multiple mp3 or wma files i.e. 1 per track. It allows you to add multiple tracks from any folder(s) (Ctrl + A to select all tracks from the Open File dialog box).

Once added to the list they can be sorted, moved up/down and deleted.

You can either generate lists for the contents of you SD card using the “Create Play List File” option, or you can add files from various locations on your system and copy them and the playlist to the SD card using the “Copy Music and Play List to Folder” menu option.

You will need to create the shortcuts using active sync and put them in the phones menu as mentioned elsewhere on this forum.

The software does not require any installation and can be run from any location.

Please see the licence agreement. It is provided “as is” as freeware with no support etc. If you don’t like it – then delete it!!

I have only tested it on Windows XP but is should work on 2000/98.

Please note it has undergone only minimal testing.

Have a look and PM me with comments suggestions etc. I’m not promising to do anything else to it though.

Is is only 44K and can be downloaded from:

http://www.fox-ts.nildram.co.uk/AsxMaker/AsxMaker.zip

Adrian :!:

Posted

I've downloaded this and it only searches my C drive. All my music is on another hard drive (D).

Is there a way of telling the prog to change drives? I can't see one that's obvious.

Thanks

nathan

Guest adrianfox
Posted
I've downloaded this and it only searches my C drive.  All my music is on another hard drive (D).

Is there a way of telling the prog to change drives?  I can't see one that's obvious.

Thanks

nathan

Just use the dropdown list in the file selector dialog, the one next to "Look In:". It's a standard windows file selector.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.