2017-06-14 140 views
0

我想以某種特定方式將兩個文本文件文本合併到一個文本文件中。我有很多文本文件,所以我想讓這個過程自動化。我想爲此學習蘋果腳本。如何從兩個文本文件中創建一個文本文件使用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

答案完全取決於具體的方式是什麼 - 所以你將需要更forthco明! –

+0

因此,我們將第一個文件的第一行和第二個文件的第一行寫入第三個文件。我們如何推斷第一個文件,第二個文件和輸出文件的名稱? –

+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

我在找上面那種結果 –

相關問題