[英]Apple Script: Copy file (being selected from prompt) to another location
I am struggling with my Apple Script.我正在为我的 Apple 脚本而苦苦挣扎。 I am asking to select a file and the selected file needs to be copied to another location.
我要求 select 一个文件,并且需要将所选文件复制到另一个位置。 I am new to Apple Scripting, so probably made some mistake.
我是 Apple Scripting 的新手,所以可能犯了一些错误。 I tried different versions with "copy" instead of "duplicate" or "alias" instead of "file", but nothing worked so far.
我尝试了使用“复制”而不是“重复”或“别名”而不是“文件”的不同版本,但到目前为止没有任何效果。 Hope, somebody can help me figure this out.
希望,有人可以帮我解决这个问题。
This is what I scripted so far (I get an AppleEvent timed out):这是我到目前为止编写的脚本(我得到一个 AppleEvent 超时):
set DefaultPath to POSIX file "/Users/jan/Library/Mobile Documents/com~apple~CloudDocs/FOLDER/Test"
set DestFolder to "/Users/jan/Library/Mobile Documents/com~apple~CloudDocs/FOLDER/Destination"
set theFile to (choose file with prompt "Select file:" default location (DefaultPath))
tell application "Finder"
duplicate theFile to folder DestFolder
end tell
The problem is that the Finder doesn't support POSIX paths.问题是 Finder 不支持 POSIX 路径。
I recommend to use a relative path path to library folder from user domain
and HFS paths (colon separated)我建议使用
path to library folder from user domain
的相对路径路径(冒号分隔)
To satisfy the location
parameter of choose file
put the alias
keyword in front of the (HFS) path为了满足
choose file
的location
参数,将alias
关键字放在(HFS)路径的前面
set cloudDocs to (path to library folder from user domain as text) & "Mobile Documents:com~apple~CloudDocs:"
set DefaultPath to cloudDocs & "FOLDER:Test:"
set DestFolder to cloudDocs & "FOLDER:Destination:"
set theFile to (choose file with prompt "Select file:" default location (alias DefaultPath))
tell application "Finder"
duplicate theFile to folder DestFolder
end tell
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.