tell application "iTunes"
set Thehe to (tracks of view of front browser window)
set PlayCountsToImport to (played count of item 8 of Thehe)
end tell
However this doesn’t work:
tell application "iTunes"
set Thehe to (tracks of view of front browser window)
set PlayCountsToImport to (played count of every item of Thehe)
end tell
set PlayCountsToImport to 0
tell application "iTunes"
set Thehe to (tracks of view of front browser window)
repeat with anItem in Thehe
set PlayCountsToImport to PlayCountsToImport + (played count of anItem)
end repeat
end tell
tell application "iTunes"
set PlayCountsToImport to (played count of (every track of first library playlist whose duration is greater than 100 and genre is not missing value))
end tell
-->{1, 1, 1, 2, 0, 1, 2, 0, 2, 2, 0, 1, 0, 2, 2, 1, 4, 1}
If you are doing it manually in iTunes, or via some other means, this may be what you are looking for:
tell application "iTunes"
make new playlist with properties {name:"Temp"}
duplicate (every track of view of front browser window) to playlist "Temp"
set PlayCountsToImport to played count of (every track of playlist "Temp")
delete playlist "Temp"
end tell
many thanks for your effort, unfortunately I can’t work it out with your input. The problem is that the filter I’m applying to come up with the subset is custom, it’s computed with an aggregate of iTunes criteria. Therefore I end up with a list (let’s say a list of Database ID) that I want to use to call up track fields. Let’s say, {6374, 762, 8271} is a list of iTunes Database IDs, now how can I get the played counts of these Tracks whose Database ID are in that list with a single Event, no loop. As underlined in the thread history, iTunes is able to call a single field of a list of songs and moreover extremely fast, I wish I could do the same by feeding iTunes with whatever it needs to make this query!
OK, I think I see what you mean. The database ID property is of limited usefulness for iTunes scripting, especially with what you are trying to do; you simply have to loop it to get what you need. There are however, methods to create an extemely fast loop that is close to instantaneous. Plus, I still believe we may be able to come up with a “one-liner” if we look at your filtering method from a different point of view. Would it be possible for you to post more details on that?
Craig, thanks for your input, I came with something acceptable by just loading all the data I need even if most of it isn’t useful, at least it’s fast because done with a single event. However I would be interested to know how you can come with a fast loop based on an event because I haven’t been able to come with anything fast. Let’s say you loop 10’000 and each loop calls for an Apple event, let’s to retrieve Ratings, definitively not fast here, would you have any hint?