Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

macos - 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

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 script file as a Application. When i click on script file jar get run.

My requirement

I would like get the name of file that has been dropped onto the script file and would like to pass the name of that dropped file as an argument to my jar.

I have implemented this in Windows but could not working similar on MAC O.S.

On Windows

I have placed a BAT file to Boot JAR along with the absolute file name, that has been dropped on the bat file on windows. @echo %* will give me the list of files that has been dropped onto Batch file.

@echo %* @pause java -jar RunMyJar.jar %*

Similar i would like to implement in MAC O.S.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I found the following example at: Ben's AppleScript Snippets:

on open of finderObjects -- "open" handler triggered by drag'n'drop launches
  repeat with i in (finderObjects) -- in case multiple objects dropped on applet
    displayName(i) -- show file/folder's info
    if folder of (info for i) is true then -- process folder's contents too
      tell application "Finder" to set temp to (entire contents of i)
      repeat with j in (temp)
        display dialog j as string -- example of doing something with each item
      end repeat
    end if
  end repeat
end open

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.5k users

...