2009-12-28 63 views
1

如何搜索符合特定條件的每首歌曲?例如,如:如何使用Applescript搜索iTunes?

tell application "iTunes" 
    set tracks to (every file track of playlist "Library" whose name contains "Green") 
    repeat with t in tracks 
     display dialog (t as string) 
    end repeat 
end tell 

回答

4

就像那樣,除了兩件事;首先,tracks是iTunes腳本字典中的保留字,因此用其他名稱替換(,例如ts);第二,你不能只將一首曲目轉換爲t as string;你必須選擇你想要的信息。例如,如果你想要這個名字,你可以使用name of t as string;如果你想要更多的細節,你可以做name of t & " - " & artist of t;等等。還要注意的是,如果你想要一個更復雜的謂詞,你可以直接應用whose條款;例如,file tracks whose name contains "Green" and artist contains "Bird"

如果你想打高爾夫球腳本一點,你可以用下面的替換:

tell application "iTunes" 
    repeat with t in (file tracks whose name contains "Green") 
     display dialog (name of t as string) 
    end repeat 
end tell 

卸下of playlist "Library"可能會產生稍有不同的結果,但可能不會。它沒有在我的快速測試中。

+0

啊,謝謝你指出這是一個保留字。改變它做了伎倆。謝謝! – Bill 2009-12-29 02:58:39