2011-12-13 39 views
0

無法從基於它的播放列表選擇一個尋跡軌道的文件系統路徑(位置)。見下文。AppleScript的:在播放列表由它的文件系統路徑

我把箭頭放在每個命令的結果之前。

在第一行,我成功地找到播放列表「測試」的第一首曲目體裁「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 

回答

1

就讀了對AppleScript的,並得到了其與在軌道的顯式循環工作:(見下文)

爲什麼上面的例子中不起作用一種可能的解釋是,「第一軌道播放列表「測試」,其位置是......」返回對象說明符的列表(例如播放列表‘測試’等的第一首曲目的位置),而不是實際位置的列表 - 即現在缺少的是‘獲取’命令返回您在下面重複循環內看到的實際位置。這將解釋描述符類型不匹配,也許?我不具備的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