On MAC O.S., how to get the name of files that has been dropped onto apple script to boot JAR with the name of file as a argument to JAR

前端 未结 3 567
Happy的楠姐
Happy的楠姐 2020-12-21 12:50

In Script editor i have written a command to boot the JAR.

do shell script \"cd /Desktop/RunJar/; java -jar RunMyJar.jar\"

and Saved as

3条回答
  •  爱一瞬间的悲伤
    2020-12-21 13:01

    To add to Paul's answer

    on open of finderObjects

    repeat with currFile in finderObjects
       -- ok, we have our current item. But it's an "alias": a Mac OS path
       -- not a POSIX path
       set unixPath to POSIX path of currFile
    
       set base to do shell script "dirname " & unixPat
       set fname to do shell script "basename " & unixPath
       -- you could ask the Finder to give this to you too -- I'll use this way because
       -- I'm guessing it's more familiar to you
    
       do shell script "cd '" & base & "';" & " java -jar " & fname
    end repeat  
    

    end open

提交回复
热议问题