Hey all,
I wrote a simple program that syncs my iTunes playlists with folders on
my machine. Because I download a lot of music (mixes/techno) I organize
by creating folders based on a month's downloads. I sometimes find a
site with an artist that has multiple tracks, so I'll create a
subfolder for that month's downloads with that artist's name (like
Nullsleep at http://www.nullsleep.com).
Anywho, my very simple VB program clears/creates playlists based on a
root folder. The following code is for deleting playlists and even
though it's Visual Basic it should make sense:
dim iPlay as IITPlaylist
dim iTunes as New iTunesApp
For Each iPlay in iTunes.LibrarySource.Playlists 'for each playlist
If Instr(1, iPlay.Name, "::") > 0 Then 'if named w/ "::"
iPlay.Delete 'get rid of it
End If
Next
The strange thing here is that in order for it to work I just have to
run it multiple times. I'm assuming that part of my problem is that
I'm modifying the collection I'm iterating through, but how would one
go about this?
Thanks much.
david.seruyange@gmail.com - 27 Oct 2005 23:03 GMT
Oof. Don't you hate it when you post and then come up with a fix
*right after* you've posted? I thought about how I was modifying the
collection from my loop and revised the code as such to make it work:
dim iPlay as IITPlaylist
dim iTunes as New iTunesApp
Sub ClearLists
For Each iPlay in iTunes.LibrarySource.Playlists 'for each playlist
If Instr(1, iPlay.Name, "::") > 0 Then 'if named w/ "::"
iPlay.Delete 'get rid of it
ClearLists
Exit For
End If
Next
End Sub