Wednesday, June 08, 2005

VBScript - Add a file to iTunes

Rab dropped a comment on my iPodder VBScript(Copy New PodCast to My SD Card) post with an example of how to adding a file to iTunes. After looking at his script, I thought it might be cool to see if I could create a Playlist in iTunes and then add the file.

001 ' Variables
002 dim iTunes, FullPath, playlist
003
004 FullPath = "C:\Music\Machups\wewillrockbeverlyhills.mp3"
005
006 ' Connect to iTunes app
007 set iTunes = CreateObject("iTunes.Application.1")
008
009 ' Create playlist
010 set playlist = iTunes.LibrarySource.Playlists.ItemByName("My Test")
011 if playlist is Nothing then
012 iTunes.CreatePlaylist("My Test")
013 set playlist = iTunes.LibrarySource.Playlists.ItemByName("My Test")
014 end if
015
016 ' Add file to playlist
017 playlist.AddFile(FullPath)
018
019 set iTunes = Nothing
020 set playlist = Nothing


Line 10 tries to get a reference to a Playlist called “My Test”. If the Playlist does not exist the playlist variable will be Nothing. If the playlist variable is Nothing, “My Test” Playlist will be created (line 12) and on line 13 the playlist variable will get a reference to the newly created Playlist. Then on line 17 the mp3 file is added to that Playlist.

Friday, June 03, 2005

Google-fu

There are some great Google commands over at Coding Horror. (I keep going back to this page, maybe because of the Ninja.)

Also, Engadget has a cool article on how to customize a Google map.