我做了以下脚本,以识别没有艺术品的iTunes歌曲。它基于我在网上找到的其他脚本。
tell application "iTunes"
repeat with a in every track of playlist "Library"
if not (exists (artwork 1 of a)) then
add (get location of a) to (playlist "noart")
end if
end repeat
end tell
它似乎工作正常,编译得很好,因为我可以在事件日志窗口中显示它:
tell application "iTunes"
count every track of playlist "Library"
--> 10684
exists artwork 1 of item 1 of every track of playlist "Library"
--> true
exists artwork 1 of item 2 of every track of playlist "Library"
--> true
但是经过400首曲目后,它开始缓慢运行,而且在一千首曲目之后,AppleScript停止响应。
我想也许我可能会耗尽我的mac内存,但在Activity Monitor中,我可以看到Applescript正在消耗100%的CPU和不到50MB的内存。我在macbook pro上运行macos 10.7.4(带有4GB内存的i7)。
正如你所看到的,我的itunes库有10684个曲目。它不是一个小型图书馆,但它不是一个巨大的图书馆。
有人有什么建议吗?或者用于识别没有艺术品的曲目的脚本?
TIA,
鲍勃
答案 0 :(得分:2)
这是我使用的。我的主要建议是使用“复制”而不是“添加”,然后您不需要获取轨道的位置。此外,你会看到我正在使用“引用”大多数事情,这使得它更快地工作。我还会在运行时创建带有时间戳的“无艺术品”播放列表,这样我就能看到我运行脚本的时间。
set d to current date
set missingTracksCount to 0
tell application "iTunes"
set isFixedIndexing to fixed indexing
if not isFixedIndexing then set fixed indexing to true
-- make a new playlist to hold the tracks
set newPlaylist to make new playlist
set name of newPlaylist to "No Art - " & month of d & " " & day of d & " " & time string of d
set mainPlaylist to a reference to playlist "Library"
set noArtworkPlaylist to a reference to newPlaylist
set trackCount to count of tracks of mainPlaylist
repeat with i from 1 to trackCount
set trackRef to (a reference to (track i of mainPlaylist))
if (count of artworks of trackRef) is less than 1 then
duplicate trackRef to noArtworkPlaylist
set missingTracksCount to missingTracksCount + 1
end if
end repeat
if not isFixedIndexing then set fixed indexing to isFixedIndexing
display dialog "Finished!" & return & (missingTracksCount as text) & " tracks didn't have artwork." buttons {"OK"} default button 1 with icon note giving up after 5
end tell