|
  
|
|
|
#1 (permalink) |
|
I Scream, U Scream, We...
zB Writer
Section Staff Elite Zuner Join Date: Mar 2007
Location: Fresno, CA USA
Posts: 2,151
Reputation: 218
|
I dunno if this should be in the Tutorials section, but I found this on the forums.zune.net. This guy made a simple program that will instantly sort your playlists by either track title, album, artist name, and track artist name. (isn't the last two the same?)
As an added bonus, it will also tell you the number of songs and length of your playlist. Anyhoo - Here's what you do:
Here's the script: 'Start Copy Here Code:
'Sort Options are "src", "albumTitle", "albumArtist", "trackTitle", "trackArtist", "duration")
SortBy = "trackTitle"
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set xObj = CreateObject("microsoft.xmldom")
Set xObj2 = CreateObject("microsoft.xmldom")
For Each strArgument in Wscript.Arguments
If xObj.Load(strArgument) Then
strNewList = "<?zpl version=""2.0""?><smil>" & vbcrlf
strNewList = strNewList & xObj.DocumentElement.SelectSingleNode("head").xml
strSortedSeq = SortXMLDoc(xObj.DocumentElement.SelectSingleNode("body"))
If strSortedSeq = "Error" Then
MsgBox "Error sorting this playlist"
Else
strNewList = strNewList & strSortedSeq
strNewList= strNewList & "</smil>"
If xObj2.LoadXML(strNewList) Then
Set objFile = objFSO.OpenTextFile(strArgument, ForWriting)
objFile.Write strNewList
objFile.Close
For Each metaNode in xObj.DocumentElement.SelectSingleNode("head").childNodes
Select Case metaNode.getAttribute("name")
Case "itemCount"
numSongs = metaNode.getAttribute("content")
Case "totalDuration"
numMiliSecond = metaNode.getAttribute("content")
numMinutes = Cint((numMiliSecond / 1000) / 60)
numSeconds = Cint((numMiliSecond / 1000) mod 60)
numHours = Cint(numMinutes / 60)
numMinutes = Cint(numMinutes mod 60)
End Select
Next
MsgBox ("Playlist: " & xObj.DocumentElement.SelectSingleNode("head").text _
& vbcrlf & "Length: " & numHours & " hours, " & numMinutes & " Minutes, " & numSeconds & " seconds" _
& vbcrlf & "Tracks: " & numSongs _
& vbcrlf & "Sorted By: " & SortBy )
Else
MsgBox "Could not sort this playlist"
End If
End If
Else
MsgBox "Could not load this playlist"
End If
Next
Function SortXMLDoc(xmlDoc)
Dim bf
Dim xslDoc
Dim rsltDoc
bf = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/TR/WD-xsl'>"
bf = bf & "<xsl:template match='/'><xsl:apply-templates/>"
bf = bf & "</xsl:template>"
bf = bf & "<xsl:template match='*|@*|text()|pi()|comment()'>"
bf = bf & "<xsl:copy><xsl:apply-templates"
bf = bf & " select='*|@*|text()|pi()|comment()'/></xsl:copy>"
bf = bf & "</xsl:template>"
bf = bf & "<xsl:template match='*[media]'>"
bf = bf & "<xsl:copy><xsl:apply-templates select='media'"
bf = bf & " order-by='@" & SortBy & "'/></xsl:copy>"
bf = bf & "</xsl:template>"
bf = bf & "</xsl:stylesheet>"
Set xslDoc= CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
If xslDoc.LoadXML(bf) Then
SortXMLDoc = xmlDoc.TransformNode(xslDoc)
SortXMLDoc = Replace(SortXMLDoc,"></media>"," />" & vbcrlf)
SortXMLDoc = Replace(SortXMLDoc,"é","e")
SortXMLDoc = Replace(SortXMLDoc,"à","a")
SortXMLDoc = Replace(SortXMLDoc,"ü","u")
SortXMLDoc = Replace(SortXMLDoc,"ö","o")
Else
SortXMLDoc = "Error"
End If
End Function
You can also modify the script to Sort by other fields. The fields available are: * "src" - Location * "albumTitle" - Album * "albumArtist" - Album Artist * "trackTitle" - Song * "trackArtist" - Artist * "duration" - Length Change the script by modifying the second line: SortBy = "trackTitle" to SortBy = an option from above - Must be copied exact, include the Quotes, it is case sensitive.
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. I'm an To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ...Do you know what the original ZuneMarketplace looked like? Last edited by ACE : 01-14-2008 at 03:36 PM. ![]() ![]() ![]() |
|
|
|
|
#3 (permalink) |
|
Jr. Member
Join Date: Nov 2006
Posts: 362
Reputation: 30
|
this script doesnt work for me when sorting by song "Title". it destroy my Playlist.
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. Black Zune 80 & Samsung YH-J70 + Zune 80 Premium + AKG K26p + JVC HA-FX33 Blue -Marshmallows- To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
#4 (permalink) |
|
I Scream, U Scream, We...
zB Writer
Section Staff Elite Zuner Join Date: Mar 2007
Location: Fresno, CA USA
Posts: 2,151
Reputation: 218
|
huh...it worked for me. Did you copy AFTER the 'start copy here' or before that line? I copied after (I didn't include the 'start here' stop here' in the script.
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. I'm an To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ...Do you know what the original ZuneMarketplace looked like? ![]() ![]() ![]() |
|
|
|
|
#5 (permalink) |
|
Support Team
Moderator Ultimate Zuner Join Date: Apr 2007
Location: What a stalker!
Posts: 6,441
Reputation: 265
|
ACE, you should put the stuff people need to copy in a code box. It will make it easier to see.
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. Do you live outside of the US, have Paypal, and want the Zune Pass? If so PM or visit my To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. . ![]() |
|
|
|
|
#6 (permalink) |
|
I Scream, U Scream, We...
zB Writer
Section Staff Elite Zuner Join Date: Mar 2007
Location: Fresno, CA USA
Posts: 2,151
Reputation: 218
|
Good idea - EDITED
![]()
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. I'm an To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ...Do you know what the original ZuneMarketplace looked like? ![]() ![]() ![]() |
|
|
|
|
#7 (permalink) |
|
Zuner
Join Date: Jun 2007
Posts: 78
Reputation: 11
|
I'm not the most computer literate person but where do I find this playlist directory. I've opened up the zune folder in program files and looked. I don't see anything named as the "Playlist Directory". Am I looking in the wrong place?
Edit: My OS is Vista Ultimate. Last edited by elmastero1 : 01-15-2008 at 05:39 PM. |
|
|
|
|
#8 (permalink) |
|
Jr. Member
Join Date: Nov 2007
Location: New York
Posts: 263
Reputation: 15
|
its on the zune, u need the hard drive hack which is still buggy in the fact that it dont work most of the time
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
![]() |
| Thread Tools | |
|
|
| |