0

アートワークのない 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 トラックを超えると動作が遅くなり、1000 トラックを超えると AppleScript が応答しなくなります。

Mac のメモリを使い果たしているのではないかと思ったのですが、Activity Monitor を見ると、Applescript が 100% の CPU と 50MB 未満のメモリを消費していることがわかります。Macbook Pro(4GB RAMのi7)でmacos 10.7.4を実行しています。

ご覧のとおり、私の iTunes ライブラリには 10684 のトラックがあります。小さな図書館ではありませんが、巨大な図書館でもありません。

誰かアドバイスはありますか?それとも、アートワークのないトラックを識別するためのスクリプトですか?

ティア、

ボブ

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 に答える