2016-09-19 61 views
-1

有人可以告訴我如何使用Applescript將文本追加到文件的末尾嗎?我使用腳本編輯器記錄器來創建一個宏,幫助我清理一些HTML標記。現在我想要宏到文件的末尾並寫一個句子。在Applescript中是否有'goto eof'命令?AppleScript:轉到文件結尾並寫入文本?

謝謝!

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 "&nbsp;" 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 

回答

0

這裏是你如何在做的TextWrangler此:

tell application "TextWrangler" 
    select insertion point after last character of text window 1 
    set selection to "hello world!" 
end tell 

的語法將是獨一無二的你正在使用的文本應用程序。另外,您還可以使用applescript將文本追加到文件中,而無需在其他應用程序中打開文件。 (只搜索「applescript append text」)