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".

任何帮助都将不胜感激。

干杯

Finder术语中的

applications folder不指向标准文件夹/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

最新更新