我已创建目录结构并将a
文件放在A
目录中:
~/A
~/B
在AppleScript中,我尝试将文件a
从A
移至B
。这是我的代码:
on run
tell application "Finder"
move POSIX file "~/A/a" to POSIX file "~/B"
end tell
end run
但是当我运行脚本时,我收到错误:
error "Finder got an error: Handler can’t handle objects of this class." number -10000
这是我的问题的简化版本。请有人帮帮我吗?
答案 0 :(得分:5)
尝试:
set myFile to POSIX file (POSIX path of (path to home folder) & "A/a.txt")
set myFolder to POSIX file (POSIX path of (path to home folder) & "B")
tell application "Finder" to move myFile to myFolder
-- OR
set myFile to (path to home folder as text) & "A:a.txt"
set myFolder to (path to home folder as text) & "B"
tell application "Finder" to move myFile to myFolder