Advertisement



Go Back   Zune Boards > Zune Discussions > Zune Talk

New Member?



 
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Zune Talk Talk anything related to the Zune.

Closed Thread
 
LinkBack Thread Tools
Old 01-11-2008, 03:25 PM   #1 (permalink)
ACE
I Scream, U Scream, We...
zB Writer
Section Staff
Elite Zuner
 
ACE's Avatar
 
Join Date: Mar 2007
Location: Fresno, CA USA
Posts: 2,151
Reputation: 218
Send a message via Yahoo to ACE
Awards Showcase
Most dedicated 
Total Awards: 1
Default Sort your Playlists


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:

  1. To use this script you can copy the script below from the line that starts 'Start Copy Here. And get all the lines until 'End Copy Here.
  2. Paste the entire script (72 lines) into notepad.
  3. Save the file in your Playlists directory as Sort By Track.vbs.
  4. To sort a playlist, drag that playlist to the appropriate script. It sorts the playlist and saves it. You can do this while Zune is running and the results are immediately shown in the playlist.


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
'End Copy Here

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.






ACE is offline  
Old 01-12-2008, 09:09 PM   #2 (permalink)
Jr. Member
 
Samo's Avatar
 
Join Date: Nov 2007
Location: New York
Posts: 263
Reputation: 15
Send a message via AIM to Samo
Default

nice one, too bad the hard drive hack dont work for me :/
__________________

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.




Samo is offline  
Old 01-14-2008, 01:09 PM   #3 (permalink)
Jr. Member
 
Join Date: Nov 2006
Posts: 362
Reputation: 30
Send a message via MSN to Ricardo Dawkins
Default

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.





Ricardo Dawkins is offline  
Old 01-14-2008, 03:21 PM   #4 (permalink)
ACE
I Scream, U Scream, We...
zB Writer
Section Staff
Elite Zuner
 
ACE's Avatar
 
Join Date: Mar 2007
Location: Fresno, CA USA
Posts: 2,151
Reputation: 218
Send a message via Yahoo to ACE
Awards Showcase
Most dedicated 
Total Awards: 1
Default

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?






ACE is offline  
Old 01-14-2008, 03:29 PM   #5 (permalink)
Support Team
Moderator
Ultimate Zuner
 
Join Date: Apr 2007
Location: What a stalker!
Posts: 6,441
Reputation: 265
Default

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.
.




Gregory is offline  
Old 01-14-2008, 03:38 PM   #6 (permalink)
ACE
I Scream, U Scream, We...
zB Writer
Section Staff
Elite Zuner
 
ACE's Avatar
 
Join Date: Mar 2007
Location: Fresno, CA USA
Posts: 2,151
Reputation: 218
Send a message via Yahoo to ACE
Awards Showcase
Most dedicated 
Total Awards: 1
Default

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?






ACE is offline  
Old 01-15-2008, 05:19 PM   #7 (permalink)
Zuner
 
Join Date: Jun 2007
Posts: 78
Reputation: 11
Default

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.



elmastero1 is offline  
Old 01-15-2008, 09:03 PM   #8 (permalink)
Jr. Member
 
Samo's Avatar
 
Join Date: Nov 2007
Location: New York
Posts: 263
Reputation: 15
Send a message via AIM to Samo
Default

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.




Samo is offline  
Old 01-29-2008, 01:37 PM   #9 (permalink)
Experienced Zuner
 
k-man2's Avatar
 
Join Date: Nov 2007
Location: Utah
Posts: 229
Reputation: 11
Default

I think we need a way to create a playlist without doing it on the computer. This would help me a lot.




k-man2 is offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -8. The time now is 01:42 AM.

 
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC8
vB Ad Management by =RedTyger=
(C) ZuneBoards 2006-2007
Copyright © 2006 - 2008 Zune Boards | About Zune Boards | Legal | A member of the Crowdgather Forum Community