在脚本编辑器中,我编写了一个命令来启动 JAR。
执行 shell 脚本“cd/Desktop/RunJar/; java -jar RunMyJar.jar”
并另存为脚本文件作为应用程序。当我单击脚本文件 jar 时,就会运行。
我的要求
我想获取已拖放到脚本文件中的文件的名称,并希望将该拖放文件的名称作为参数传递给我的 jar。
我已经在 Windows 中实现了此功能,但无法在 MAC 操作系统上进行类似的工作
在 Windows 上
我已将 BAT 文件连同绝对文件名一起放置到 Boot JAR 中,该文件已被拖放到 Windows 上的 bat 文件中。 @echo %* 会给我已放入批处理文件的文件列表。
@echo %* @暂停 java -jar RunMyJar.jar %*
类似我想在 MAC 操作系统中实现
谢谢。
最佳答案
我在以下位置找到了以下示例: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
关于macos - 在 MAC 操作系统上,如何获取已放入 Apple 脚本的文件名,以文件名作为 JAR 的参数来启动 JAR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2184236/