2016-09-19 19 views
-1

Applescriptを使ってファイルの最後にテキストを追加する方法を教えてもらえますか? Script Editorレコーダーを使って、いくつかの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"を検索してください)

関連する問題