我只想将图像从一个文件夹移动到另一个文件夹,替换其中已经存在的一个:
tell application "Finder"
copy file "/Users/xx/Documents/img.jpg" to folder "/Users/xx/Documents/State"
end tell
[运行时,我收到一条错误消息,说
Finder出现错误:无法将文件夹[path]设置为文件[path]“。”文件夹[path]中的-10006
请帮助我!
尝试:
tell application "Finder"
duplicate POSIX file "/Users/xx/Documents/img.jpg" to POSIX file "/Users/xx/Documents/State" with replacing
end tell
或
tell application "Finder"
move POSIX file "/Users/xx/Documents/img.jpg" to POSIX file "/Users/xx/Documents/State" with replacing
end tell
正如@adayzdone所指出的,由于您使用的是Posix样式的路径而未声明它,因此出现错误。
另一种方法是使用冒号分隔的HFS路径,如下所示:
move file "Macintosh HD:Users:xx:Documents:img.jpg" ¬ to "Macintosh HD:Users:xx:Documents:State:" with replacing
用冒号分隔的路径,您需要包括整个内容,包括卷名(我假设此处是Macintosh HD),否则它将抛出我们的好朋友错误10,006。
它帮助了我: