0

iTunes ライブラリに曲を追加し、アーティスト名、アルバム名、および曲名で情報を設定できる自動化ワークフローを作成しました。ただし、トラックをインポートするとカバーレスになるため、アートワークを自動的に追加する方法を探していました。方法の 1 つは、iTunes の「Get Album Artwork」を使用することでした。これに関する問題は、それが提供されたとしても、非常に良いアートワークを提供しないことが多いということです.

「ダウンロード」フォルダに保存されているアートワークを持っていなかった曲のアートワークをダウンロードすることにしました。スクリプトに渡すのinputは、アートワークとして曲に追加したい .jpg ファイルです。問題は、このスクリプトを実行するたびに、エイリアス ファイルをファイル タイプにできないというメッセージが表示されることです。エラーメッセージは次のとおりです。

タイプ ファイルにエイリアス "Macintosh HD:Users:Nilay:Downloads:Avicii - True - Hey Brother.jpg" を作成できません。

Automatorの「Filter Finder Items」を使用してファイルを見つけたので、ファイルが見つからない理由はありません。正しいファイルに渡されていることがわかっています。

実際のファイルではなくファイルのテキストを渡そうとしましたが、それでも同じメッセージが表示されました。最初のいくつかのコメントは、私がこのエラー メッセージを回避しようとしたいくつかの方法ですが、残念ながら、どれもうまくいきませんでした。

このエラー メッセージを解決する方法や、iTunes -> 曲を選択 -> 情報を取得 -> アートワーク -> アートワークを追加. AppleScript またはワークフローを使用してこのアクションを自動化する方法を誰かが説明できれば、それも実現可能です。ありがとうございました!!!

on run {input, parameters}

    --set jpegFilename to input
    --set jpegFilename to "/path/to/some/artwork.jpg"
    --set jpegFile to (POSIX file jpegFilename)
    --set jpegFile to (jpegFilename as POSIX file)
    --tell application "System Events" to set jpegFile to (input as POSIX file)
    set jpegFile to input

    tell application "Image Events"
        set myImage to open (jpegFile as file)
        -- the below line needs HFS syntax pathname, eg: MyComputer:Users:liquidx:
        -- save myImage as PICT in (file ":path:to:some:temporary.pict")
        save myImage as PICT in (POSIX file jpegFile)
        close myImage
    end tell

    tell application "iTunes"
        set myTrack to current track
        set artworkCount to count of artwork of myTrack
        -- the below line needs HFS syntax pathname, eg: MyComputer:Users:liquidx:
        -- set myArt to read (file ":path:to:some:temporary.pict") from 513 as picture
        set myArt to read (POSIX file jpegFile) from 513 as picture
        if artworkCount > 0 then
            set data of artwork (artworkCount + 1) of current track to myArt
        else
            set data of artwork 1 of current track to myArt
        end if
    end tell

    tell application "Image Events"
        -- delete (file ":path:to:some:temporary.pict")
        delete (POSIX file jpegFile)
    end tell

end run
4

1 に答える 1

0

inputエイリアス指定子のリストです。まず、繰り返しループが必要です

repeat with jpegFile in input

またはリストの最初の項目を取得します

set jpegFile to item 1 of input

次に、とにかくエイリアス指定子を期待するopenコマンドでImage Eventsあるため、強制は必要ありません。

set myImage to open jpegFile
于 2016-02-29T05:58:42.553 に答える