如何使用Applescript统计iTunes中的已检查项目

如何使用Applescript统计iTunes中的已检查项目,applescript,itunes,Applescript,Itunes,我正在尝试创建一个小脚本,它获取选定项的列表,并统计每个选定项在库中其他位置出现的次数。如果存在重复项,则关闭复选标记;如果这是唯一的副本,则打开复选标记 这很有效 但我想做的是让它只检查已检查歌曲库。但当我在第三行的末尾添加“enabled”位时,脚本超时 repeat with entry in selection -- "selection" is a concept implemented in iTunes set a to artist of entry set n

我正在尝试创建一个小脚本,它获取选定项的列表,并统计每个选定项在库中其他位置出现的次数。如果存在重复项,则关闭复选标记;如果这是唯一的副本,则打开复选标记

这很有效

但我想做的是让它只检查已检查歌曲库。但当我在第三行的末尾添加“enabled”位时,脚本超时

repeat with entry in selection -- "selection" is a concept implemented in iTunes 
    set a to artist of entry
    set n to name of entry
    set x to count of (file tracks whose name contains n and artist contains a and enabled is true)
    ...
    display dialog x
end repeat
如果我取出
并启用为true
,它将以预期的两倍快的时间完成,结果与预期一致


和enabled为true时
在行尾发生了一些神秘的事情。显然,我检查错误了这里有一个快速解决方法:

tell application "iTunes"
    repeat with entry in selection -- "selection" is a concept implemented in iTunes 
        set a to artist of entry
        set n to name of entry
        set myTracks to (file tracks whose name contains n and artist contains a)
        set x to {}
        repeat with aTrack in myTracks
            if aTrack's enabled = true then set end of x to aTrack
        end repeat
        display dialog (count x)
    end repeat
end tell