无法根据播放列表的文件系统路径(位置)从播放列表中选择曲目。见下文。
我在每个命令的结果之前放了箭头。
在第一行中,我成功地从播放列表“测试”中找到了第一首曲目“R& B”。
为什么第四行不起作用?看起来我和第1行一样只按文件系统位置搜索,而不是按类型搜索。
还有其他办法吗?
tell application "iTunes"....
set t to first track of playlist "Testing" whose genre is "R&B"
--> file track id 18476 of user playlist id 18414 of source id 72 of application "iTunes"
set l to location of track 1 of playlist "Testing"
--> alias "Lion:Users:cworth:Desktop:a.mp3"
set f to POSIX file "/Users/cworth/Desktop/a.mp3" as alias
--> alias "Lion:Users:cworth:Desktop:a.mp3"
set tt to first track of playlist "Testing" whose location is f
--> error "iTunes got an error: A descriptor type mismatch occurred." number -10001 to item
...end tell
答案 0 :(得分:1)
研究了Applescript并让它在轨道上进行了明确的循环:(见下文)
上述示例为什么不起作用的可能解释是'播放列表的第一首曲目“测试”其位置是......'返回对象说明符列表(例如播放列表的第一首曲目的位置“测试”等等而不是实际位置列表 - 即缺少的是“get”命令,它返回您在下面的重复循环中看到的实际位置。这可以解释描述符类型不匹配,也许?我没有Applescript的专业知识或动力去进一步,现在我已经有了它的工作,但我很高兴它是!
tell application "iTunes"
set f to POSIX file "/Users/cworth/Music/04 It's A Man's, Man's, Man's World.mp3"
set a to f as alias
set z to missing value
repeat with tr in tracks of playlist "Testing"
set ll to get location of tr
if ll is a then set z to ll
end repeat
end tell
log z