0

我做了以下脚本来识别没有艺术作品的 iTunes 歌曲。它基于我在 net.js 中找到的其他脚本。

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 在 1000 轨之后停止响应。

我想也许我可能会耗尽我的 mac 内存,但在 Activity Monitor 中,我可以看到 Applescript 正在消耗 100% 的 CPU 和不到 50MB 的内存。我在 macbook pro(i7 和 4GB 内存)上运行 macos 10.7.4。

如您所见,我的 iTunes 库有 10684 首曲目。它不是一个小图书馆,但也不是一个巨大的图书馆。

有人有什么建议吗?还是一个脚本来识别没有艺术品的曲目?

TIA,

鲍勃

4

1 回答 1

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
于 2012-05-13T23:44:10.510 回答