【问题标题】:Applescript editor not respondingApplescript 编辑器没有响应
【发布时间】:2012-05-13 22:00:15
【问题描述】:

我执行了以下脚本来识别没有插图的 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在1000音轨之后停止响应。

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

如您所见,我的 iTunes 库有 10684 首曲目。图书馆不算小,但也不算大。

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

TIA,

鲍勃

【问题讨论】:

  • 信息:当你遍历一个长列表时,不要使用“事件日志窗口”,因为如果“事件日志窗口”中的字符数为太高了。

标签: applescript itunes itunesartwork


【解决方案1】:

这是我使用的。我的主要建议是使用“复制”而不是“添加”,然后您就不需要获取轨道的位置。此外,您会看到我正在使用“参考”大多数东西,这使得它工作得更快。我还即时创建了带有时间戳的“无艺术作品”播放列表,这样我就可以看到我运行脚本的时间。

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

【讨论】:

  • 它在不到 30 秒的时间内扫描了我的图书馆...我将尝试更改我的脚本以识别持有它的那一行。
猜你喜欢
  • 2017-01-14
  • 1970-01-01
  • 1970-01-01
  • 2015-10-22
  • 2023-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多