Macos Applescript使用我自己的应用程序复制文件
我正在开发一个Mac OS X应用程序,在某些情况下,它需要将文件复制到Macos Applescript使用我自己的应用程序复制文件,macos,Macos,我正在开发一个Mac OS X应用程序,在某些情况下,它需要将文件复制到/Library/ScriptingAdditions 并使用下面的代码 tell application "Finder" duplicate sourcePath to destinationPath with replacing end tell 将提示一个对话框,说“Finder”想要做一些更改… 我想让对话框显示我的应用程序想要进行一些更改…. 我读过 但是它似乎不适用于AppleScript。如果您使
/Library/ScriptingAdditions
并使用下面的代码
tell application "Finder"
duplicate sourcePath to destinationPath with replacing
end tell
将提示一个对话框,说“Finder”想要做一些更改…
我想让对话框显示我的应用程序想要进行一些更改….
我读过
但是它似乎不适用于AppleScript。如果您使用shell而不是AppleScript,请求密码的对话框将显示您自己应用程序的名称。下面是一个复制文件“\u这是一个test.xyz”的示例 警告:不要只运行此脚本而不进行修改,因为它会将一个空文件添加到脚本添加文件夹中,而您可能不希望这样做。这个脚本只是一个示例 编辑:
只有当你可以将你的应用编译成一个独立的应用时,这才有效。如果您使用的是Python,则需要将Python脚本编译为具有名称的独立应用程序。密码对话框将显示独立应用程序的名称,而不是“Python”。我使用Python包“py applescript”来调用脚本,但它会说“Python想要进行更改…”我希望它说“我的应用程序想要进行更改…”我该怎么做?非常感谢你!!!只需将Python脚本编译为一个独立的应用程序。
set sourcePath to "'~/desktop/_this is a test.xyz' " -- mind extra space
set destPath to path to scripting additions folder -- change this to your destination folder
set destPath to POSIX path of destPath
set destPath to "'" & destPath & "_this is a test.xyz'"
set shellScript to "cp -n " & sourcePath & destPath
do shell script shellScript with administrator privileges