tags:

views:

38

answers:

2

Hi, I'm writing an Applescript for use in iTunes in which at some point I want to select any track from a list of tracks, but the way I expected it to work gives an error. Here's the code:

tell application "iTunes"
    set thePlaylist to the first playlist whose name is "Missing track count"
    -- ...
    -- populate a list of strings: albumList
    -- ...
    repeat with albumName in the albumList
        set theAlbum to (the tracks of thePlaylist whose album is albumName)
        display dialog "Found " & (count theAlbum) & " tracks in the album"
        set aTrack to some track of theAlbum -- ERROR OCCURS HERE
    end repeat
end tell

The error I get when I execute the script from within iTunes is:

Can't get some «class cTrk» of {«class cFlT» id 16112 of «class cUsP» id 15982 of «class cSrc» id 65 of application "iTunes", ... etc}

Now, I don't really see why it doesn't work, although I guess it must have something to do with the fact that the items in theAlbum are file tracks from a user playlist from the source from the iTunes application instead of 'just' tracks. Can anyone help me out here?

+1  A: 

In this example I use some item instead of some track, which works OK.

tell application "iTunes"
    set thePlaylist to the first playlist
    set x to (the tracks of thePlaylist)
    set aTrack to some item in x
end tell

results in

URL track id 87 of library playlist id 82 of source id 64 of application "iTunes"

Since all the items in your example inherit from track, I don't know why it doesn't work, but it doesn't.

Alex Brown
Thanks, although it doesn't answer my question, it does help me out. (Maybe I asked the wrong question.)
Jelle Fresen