Apple Script:将文件(从提示中选择)复制到另一个位置
Apple Script: Copy file (being selected from prompt) to another location
我正在为我的 Apple Script 而苦苦挣扎。我要 select 一个文件,selected 文件需要复制到另一个位置。我是 Apple Scripting 的新手,所以可能犯了一些错误。我尝试使用“复制”而不是“复制”或“别名”而不是“文件”的不同版本,但到目前为止没有任何效果。希望有人能帮我解决这个问题。
这是我目前编写的脚本(我收到 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
问题是 Finder 不支持 POSIX 路径。
我建议使用相对路径 path to library folder from user domain
和 HFS 路径(以冒号分隔)
为了满足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
我正在为我的 Apple Script 而苦苦挣扎。我要 select 一个文件,selected 文件需要复制到另一个位置。我是 Apple Scripting 的新手,所以可能犯了一些错误。我尝试使用“复制”而不是“复制”或“别名”而不是“文件”的不同版本,但到目前为止没有任何效果。希望有人能帮我解决这个问题。
这是我目前编写的脚本(我收到 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
问题是 Finder 不支持 POSIX 路径。
我建议使用相对路径 path to library folder from user domain
和 HFS 路径(以冒号分隔)
为了满足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