2017-06-14 10 views
0

特定の方法で2つのテキストファイルを1つのテキストファイルに結合しようとしています。私はこのプロセスを自動化したいので、多くのテキストファイルがあります。私はこれのためにリンゴのスクリプトを学ぼうとしています。2つのテキストファイルから1つのテキストファイルを作成する方法AppleScriptを使用したテキスト

これをAppleスクリプトでどのように実現するか。

Treat it as a two files and wanted to make a new file like this - :

textfile_One.rtf or textfile_One.txt 
{ 
    Hello World 
} 

textfile_Two.rtf or textfile_Two.txt 
{ 
    Hey Dunia 
} 

textfile_Three.rtf or textfile_Three.txt 
{ 
    Hello World 
    Hey Dunia 
} 

this kind of output of files

+0

答えは、特定の方法が何であるかに完全に依存 - あなたがはるかにする必要があります。エコ明! –

+0

したがって、最初のファイルの最初の行と2番目のファイルの最初の行を3番目のファイルに書きます。最初のファイル、2番目のファイル、出力ファイルの名前はどのように推測しますか? –

+0

あなたのアプローチを示してください –

答えて

0
tell application "TextEdit" 
    activate 
    set source_doc to open file "source 1.txt" 
    set source_doc2 to open file "source 2.txt" 
    set destination_doc to make new document 
    delay 1 
    make new paragraph ¬ 
     at end of every paragraph of text of destination_doc 
    duplicate every paragraph of text of source_doc ¬ 
     to end of every paragraph of text of destination_doc 
    duplicate every paragraph of text of source_doc2 ¬ 
     to end of every paragraph of text of destination_doc 
end tell 

OR

tell application "TextEdit" 
    activate 
    (choose file) as string 
    set source_doc to the result 
    delay 0.2 
    (choose file) as string 
    set source_doc2 to the result 
    delay 0.2 
    set source_doc to open file source_doc 
    set source_doc2 to open file source_doc2 
    set destination_doc to make new document with properties {name:"combined", name extension:"txt"} 
    delay 0.2 
    make new paragraph ¬ 
     at end of every paragraph of text of destination_doc 
    delay 0.2 
    duplicate every paragraph of text of source_doc ¬ 
     to end of every paragraph of text of destination_doc 
    delay 0.2 
    duplicate every paragraph of text of source_doc2 ¬ 
     to end of every paragraph of text of destination_doc 
end tell 
+0

私は上記の種類の結果を探しています –

関連する問題