我正在尝试使用脚本重命名Applications文件夹中的文本文件。我正在尝试以下
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".
任何帮助将不胜感激。
欢呼
答案 0 :(得分:1)
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