2012-05-13 15 views
0

アートワークを持たないiTunesの曲を特定するために、次のスクリプトを実行しました。それは私がネットで見つけた他のスクリプトに基づいています。AppleScriptエディタが応答しない

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 

しかし、4百台のトラックの後に、それはゆっくりと実行を開始し、アップルスクリプトの停止1000トラック後に応答する。

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

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

誰にもアドバイスがありますか?アートワークなしでトラックを識別するスクリプトですか?

TIA、

ボブ

+0

情報: あなたが長いリストを反復処理する場合は、「イベントログウィンドウ」内の文字の数があまりにもあれば、「アップルスクリプトエディタ」は応答しませんので、「イベントログウィンドウ」を使用していません高い。 – jackjr300

答えて

2

は、ここで私が使用しているものです。私の主な提案は、 "add"の代わりに "duplicate"を使うことで、トラックの位置を取得する必要はありません。また、私はそれをより速く動作させるほとんどのものに "参照"を使用していることがわかります。また、タイムスタンプをオンにして「アートワークなし」プレイリストを作成して、スクリプトを実行したタイミングを確認できます。

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 
+0

30秒以下でライブラリをスキャンしました...スクリプトを保持している行を特定するためにスクリプトを変更しようとします。 –

関連する問題