applescript - 将文件复制到另一个文件夹时如何修复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 上运行得非常好。
解决方案
您要将文件夹复制到一个文字字符串(路径),这可能会在运行旧系统版本的机器上失败。
删除as text
参数以获取alias
说明符
set destinationFolder to path to documents folder
推荐阅读
- google-sheets - 如何计算 Google 表格中包含单词的单元格?
- docker - ASP.NET core linux(centos) docker容器,垃圾回收的机制是什么?
- angular - 为什么我的指令没有在 Angular 的共享模块中被拾取?
- python - Concatenate two rows based on a condition using for loop
- debian - debian 9.5 版本不正确
- vue.js - 根据 v-if 渲染组件
- python - 使用 pyaudio 和 matplotlib 实时创建波形
- java - 整体执行时测试用例的问题
- ios - 具有后台模式支持位置跟踪的 iOS 应用程序会在一段时间后自动关闭(不是在每个会话中)
- c++ - 2D array value are passed like array and 0 do not get printed