macos - Applescript 重命名应用程序文件夹中的文件
问题描述
我正在尝试使用脚本重命名应用程序文件夹中的文本文件。我正在尝试以下
tell application "Finder"
set name of file "File.txt" of applications folder to "File.txt.OFF"
end tell
但这给出了一个错误:
Can’t get file "Text.txt" of applications folder.
它肯定在那里并称之为(它是复制和粘贴)。然后我尝试删除文件夹位:
set name of file "File.txt" of applications to "File.txt.OFF"
但是又出现了一个错误:
Finder got an error: Can’t set every application to "Text.txt.OFF".
任何帮助将非常感激。
干杯
解决方案
applications folder
在 Finder 术语中并不指向标准文件夹/Applications
。它似乎是对某些前 OS X 项目的遗留参考。
试试这个,但您可能没有更改名称的权限,并且无论如何都不鼓励您将任意数据(如文本文件)放入/Applications
set applicationsFolder to path to applications folder
tell application "Finder"
set name of file "File.txt" of applicationsFolder to "File.txt.OFF"
end tell
或使用System Events
tell application "System Events"
set name of file "File.txt" of applications folder of local domain to "File.txt.OFF"
end tell
推荐阅读
- excel - Excel 将不同工作簿中的数据复制到 1 个工作簿中
- javascript - 在 Next.js 中模仿 react-router-dom 嵌套路由
- arrays - Svelte 输入绑定 JSON 数组
- cmd - MSI 安装程序抛出退出代码 3010 并且无法修复它。需要帮助
- angularjs - 未捕获的错误:Angular JS 中的 [$injector:modulerr] 和 ngRoute 错误
- javascript - jQuery下一个div点击循环
- node.js - 使用get方法删除数据是正确的吗?
- deep-learning - 如何使用 Fasttext 构建 lemmatizer
- c++ - SearchPathW 冻结
- firebase - 如果存在颤动,Firestore 会增加 int 值