1

So I have this small bundle with applescript made, and it even seems to work as it should. However, it appearently doesnt open my files when it is asked to via the open utility. It works though when I use the finder. Can anybody help me? My code is this:

on open theFile
    set runner to ((path to me)'s POSIX path) & "Contents/MacOS/desk_parse"
    -- We need to escape some stuff here.
    -- Expected output: '/path/to/bundle.app//Contents/MacOS/dsk_parse' '/path/to/app.desk'
    do shell script "'" & runner & "' '" & (POSIX path of theFile) & "' &"
    --display dialog runner
end open

Again, it works from finder, but not from command line like:

open "theFile.ext"

My Info.plist rads and also accepts the extension I saved into it. So that association actualy works.

1 Answer 1

0

That is normal behavior: the open handler applies to:

  • Files dropped on the application from Finder
  • Files opened with for example tell app "Finder" open ... using path to "Your Application"

But not to:

  • Files passed as arguments to open -a
  • Files opened in the application if the application is made the default application for a file type

You might create the application with Automator or Platypus instead.

With Automator, use a Run AppleScript action like this:

on run {input, parameters}
    say (POSIX path of item 1 of input)
end run

With Platypus, check "Accept dropped items" and use a normal run handler:

#!/usr/bin/osascript

on run argv
    say item 1 of argv
end

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .