Applescript:转到文件末尾并写入文本?
有人能告诉我如何使用Applescript将文本附加到文件末尾吗?我使用脚本编辑器记录器创建了一个宏,帮助我清理一些HTML标记。现在我想让宏转到文件的末尾,写一个句子。Applescript中是否有“goto eof”命令 谢谢Applescript:转到文件末尾并写入文本?,applescript,Applescript,有人能告诉我如何使用Applescript将文本附加到文件末尾吗?我使用脚本编辑器记录器创建了一个宏,帮助我清理一些HTML标记。现在我想让宏转到文件的末尾,写一个句子。Applescript中是否有“goto eof”命令 谢谢 tell application "TextWrangler" activate open find window replace "<b>" using "<strong>" searching in text 1 of do
tell application "TextWrangler"
activate
open find window
replace "<b>" using "<strong>" searching in text 1 of document 1 options {search mode:grep, starting at top:true}
replace "</b>" using "</strong>" searching in text 1 of document 1 options {search mode:grep, starting at top:true}
replace "<i>" using "<em>" searching in text 1 of document 1 options {search mode:grep, starting at top:true}
replace "</i>" using "</em>" searching in text 1 of document 1 options {search mode:grep, starting at top:true}
replace "<span>" using "" searching in text 1 of document 1 options {search mode:grep, starting at top:true}
replace "</span>" using "" searching in text 1 of document 1 options {search mode:grep, starting at top:true}
replace " " using "" searching in text 1 of document 1 options {search mode:grep, starting at top:true}
close find window
goto eof
write "hello world!"
end tell
告诉应用程序“TextWrangler”
激活
打开查找窗口
在文档1选项的文本1中使用“”搜索替换“”{搜索模式:grep,从顶部开始:true}
在文档1选项的文本1中使用“”搜索替换“”{搜索模式:grep,从顶部开始:true}
在文档1选项的文本1中使用搜索替换“”{搜索模式:grep,从顶部开始:true}
在文档1选项的文本1中使用搜索替换“”{搜索模式:grep,从顶部开始:true}
在文档1选项的文本1中使用搜索替换“”{搜索模式:grep,从顶部开始:true}
在文档1选项的文本1中使用搜索替换“”{搜索模式:grep,从顶部开始:true}
在文档1选项的文本1中使用搜索替换“”{搜索模式:grep,从顶部开始:true}
关闭查找窗口
转到eof
写“你好,世界!”
结束语
以下是在TextWrangler中执行此操作的方法:
tell application "TextWrangler"
select insertion point after last character of text window 1
set selection to "hello world!"
end tell
语法对于您正在使用的文本应用程序是唯一的。此外,您还可以仅使用applescript将文本附加到文件,而无需在其他应用程序中打开该文件。(只需搜索“applescript追加文本”)