2

When I have the track name in quotes it successfully adds the track to the playlist "talks". See example:

tell application "iTunes"
    duplicate track "Big Ruby Conf 2013 Keynote by Jim Weirich-vIHdhaF2R2w.mp3" to      playlist "talks"
end tell

But what I want to do is pass in a command line argument for the track that I want to add to my playlist, like so:

on run argv
    tell application "iTunes"
        duplicate track argv to playlist "talks"
    end tell
end run

When I do that I get this error:

osascript add_track_to_talks.scpt  "Big Ruby Conf 2013 Keynote by Jim Weirich-vIHdhaF2R2w.mp3"
    add_track_to_talks.scpt: execution error: iTunes got an error: A descriptor type    mismatch occurred. (-10001)

I know passing command line arguments works because I wrote something simple to test it:

on run arg
    log "hello: " & arg
end run

When I run it with this command:

osascript log_test.scpt "Blake"

I get this output:

hello: Blake

Any ideas on the correct way to pass in a track name as a command line argument?

4

1 回答 1

2

您必须从 argv 中引用一个项目,这是一个列表:

on run argv
    tell application "iTunes"
        duplicate track (first item of argv) to playlist "talks"
    end tell
end run
于 2013-09-08T01:59:10.283 回答