首页 > 解决方案 > 将文件复制到另一个文件夹时如何修复applescript中的〜10006错误?

问题描述

尝试将文件复制到另一个文件夹时,脚本会引发 ~10006 错误。这仅在某些 Mac mini 计算机上发生,在其他计算机上运行良好。我不知道为什么它可以在某些计算机上运行,​​但不能在其他计算机上运行。

这是显示的错误:无法将“Macintosh HD:Users:username:Documents:”设置为应用程序“Finder”的 <>“Macintosh HD:Users:username:Downloads:new test:portal resources”。(~10006)

tell application "Finder"
set folderToBeMoved to (container of (path to me) as text) & 
"portal_resources"
set destinationFolder to path to documents folder as text
set moveFolder to duplicate folder folderToBeMoved to destinationFolder     with replacing
end tell

预期输出是将文件复制到文档文件夹。但是,在某些 Mac 上进行测试时,脚本会显示错误 ~10006。它在其他 Mac 上运行得非常好。

标签: applescript

解决方案


您要将文件夹复制到一个文字字符串(路径),这可能会在运行旧系统版本的机器上失败。

删除as text参数以获取alias说明符

set destinationFolder to path to documents folder

推荐阅读