Have (almost) written first automator action for iTunes

Hi,

I’ve written my first applescript automator application, it extracts artwork from iTunes into individual image files.

It works! Almost :frowning:

The image files are created on disk but I can’t work out how to pass them as output. I can’t find much info on this in Apple’s intro guide http://developer.apple.com/documentation/AppleApplications/Conceptual/AutomatorConcepts/index.html

If I specify com.apple.applescript.text-object under AMProvides in info.plist, I can output text strings. However if this is changed to public.image and use the applescript


set artworkData to (data of artwork 1 of itunesTrack) as picture
set end of output to artworkData

or


set finalartworkFile to (artworkFolder & theName & extension) as string
set end of output to finalartworkFile

it doesn’t work.

When you put another action after it which accepts ‘Image file’, the two don’t link and both ‘Image file’ linkers turn red. It seems likely that there’s something wrong besides the applescript but I must admit this is new to me and I haven’t got a clue.

Does anyone know how to do this properly?

Best regards,

Oliver Kohll

without seeing your on run handler it is a bit difficult.

From what you have written I believe you need to do the following.

You need to keep track of all the aliases or file references to the files you have created in a list, in my short applescript below I have assumed you called the variable where you have stored that info theFiles. The script below is only a guide of what you need to do. I don’t know the boundary conditions for your loop.


set theFiles to {}
repeat
set finalartworkFile to (artworkFolder & theName & extension) as alias
set end of theFiles to finalartworkFile
end repeat
return theFiles
end run

A better value for AMProvides is something like: com.apple.applescript.alias

I don’t have the documentation in front of me now so you will have to look up the list of types.

I hope that helps.

Great, thanks ktam, that’s it. :slight_smile:

com.apple.finder.file-or-folder-object seems to work, there may be a more appropriate one but that’ll do for now.

I’ll post my action to macscripter when it’s finished.

Cheers

Oliver