applescriptitunesautomatoritunesartwork

Set Track Artwork with AppleScript Using Existing Tracks


I am trying to make an Automater workflow that uses AppleScript. The workflow gets two tracks and passes them to the following script:

on run {input, parameters}
     set artwork of item 1 of input to artwork of item 2 of input
     return input
end run

I am trying to have the script take the artwork from one track and apply it to the other. However when run I get the following error:

A descriptor type mismatch occurred.

Any help is greatly appreciated.


Solution

  • You must specify the application. Try this :

    on run {input, parameters}
        if (count input) > 1 then
            set t2 to (item 2 of input)
            tell application "iTunes"
                if artworks of t2 is not {} then
                    set data of artwork 1 of (item 1 of input) to (get raw data of artwork 1 of t2)
                end if
            end tell
        else
            display dialog "Select two tracks first..." buttons {"OK"} cancel button 1
        end if
        return input
    end run