Want to organise your iTunes library by folder?

Soldato
Joined
7 Mar 2005
Posts
5,231
Location
The Voice Of Football
I managed to get hold of a VBScript that will let you use the 'description' field in itunes and replace it with your file path. This is particularly useful if, like me, you sort all your albums like d:music/o/oasis/definitely maybe/

Simply copy and paste the code below into notepad and save as a .vbs file.

Run the .vbs file when you have itunes open and input the number 1 in the resulting popup box to write the path of each file to the description tag. N.b. this will overwrite the description tag so if you use it, this script is not for you.



Code:
Option Explicit
 
Dim iTunesApp        ' iTunes.Application object used to access the iTunes application.
Dim tracks           ' The tracks collection object of the Library object. 
Dim FileList         ' The list of files that have been copied.
Dim i                ' A counter variable.
Dim Msg              ' A string for a message.
Dim f                ' A file object.
Dim sources
Dim source
Dim playlists
Dim playlist
Dim playlistName
Dim j
Dim m
Dim songName
Dim artist
Dim result
Dim listarray
Dim num
Dim k
Dim track
Dim numtracks
 
Set iTunesApp  = CreateObject("iTunes.Application.1")
Set sources = iTunesApp.Sources
 
DIM use_windows
Dim Playlist_list
 
'detect CSCRIPT context & use InputLine
IF Instr(lcase(wscript.FullName), "cscript")>0 THEN	
	use_windows = 0
ELSE	'detect WSCRIPT context & use native InputBox
	use_windows = 1
END IF
 
For i = 1 to sources.Count
	Set source = sources.Item(i)
	
	IF source.Kind = 1 Then
		Set playlists = source.Playlists
		if  use_windows = 0 Then
			For j = 1 to playlists.Count
				Set playlist = playlists.Item(j)
				playlistName = playlist.Name
				Wscript.Echo j & ": " & playlistName
			Next
		Else
			For j = 1 to playlists.Count
				Set playlist = playlists.Item(j)
				playlistName = playlist.Name
				Playlist_list = Playlist_list & j & ": " & playlistName & Chr(10)
			Next
		End if
		
		If use_windows = 0 Then
			Wscript.Echo ""
			Wscript.StdOut.Write "Enter comma-separated lists to process: "
			result = Wscript.StdIn.ReadLine
		Else
			result = InputBox(Playlist_list & Chr(10) & "Enter comma-separated lists to process: ", "Which Playlist(s)")
		End if
		
		
 		listarray = split(result, ",")
 		For k = 0 to UBound(listarray)
 			num = listarray(k)
 		   	Set playlist = playlists.Item(num)
 		   	playlistName = playlist.Name
 		   	If use_windows = 0 Then
	 		   	Wscript.Echo ""
	 		   	Wscript.Echo chr(9) & "Processing playlist " & num & ": " & playlistName
			End If
			 		   	
 		   	Set tracks = playlist.Tracks
 		   	numtracks = tracks.Count
 		   	If use_windows = 0 Then
	 		   	Wscript.Echo chr(9) & "tracks: " & numtracks
			End If
 		   	For m = numtracks to 1 step -1
 		   		'If m > tracks.Count Then Exit For
 		   		Set track = tracks.Item(m)
 		   		'Wscript.Echo "num: " & numtracks & " Count: " & tracks.Count & " m: " & m
 		   		
 		   		If track.Kind = 1 Then
 		   			FileList = track.Location
 		   			track.Description = FileList
 		   		End If
 		   	Next
  		   	If use_windows = 0 Then
 		   		Wscript.Echo "Finished processing playlist " & playlistName 
  		   	End If
 		Next
 		
		'End If
	End If
Next
 
Back
Top Bottom