我正在尝试编写一个通过启动代理运行的AppleScript。脚本需要编辑用户首选项plist文件,以便默认保存位置特定于该用户。我知道可以通过在模板plist中设置“〜/文档”作为位置来完成这个操作。但例如Premier Pro还需要将临时文件写入本地驱动器。为简单起见,我希望每个用户都将这些文件放置在基于其用户名的位置上。如果本地配置文件是从模板在第一次登录时创建的,则只需要运行此脚本。
我已经开始使用在此网站上找到的一些示例代码,并制作了下面的简单测试。此测试应编辑一个txt文件并用另一个单词替换一个单词。但是脚本目前无法正常工作。测试时它会在TextEdit中打开test.txt,但不会执行其他操作。也没有显示任何错误。
提前感谢您。
约翰。
我已经开始使用在此网站上找到的一些示例代码,并制作了下面的简单测试。此测试应编辑一个txt文件并用另一个单词替换一个单词。但是脚本目前无法正常工作。测试时它会在TextEdit中打开test.txt,但不会执行其他操作。也没有显示任何错误。
提前感谢您。
约翰。
replaceText("replace this", "replace with this", "/Volumes/USB_Drive/test.txt")
on replaceText(search_string, replacement_text, this_document)
tell application "TextEdit"
open this_document
set AppleScript's text item delimiters to the search_string
set this_text to the text of the front document as list
set AppleScript's text item delimiters to the replacement_text
set the text of the front document to (this_text as string)
close this_document saving yes
end tell
end replaceText