繁体   English   中英

如何使用Apple脚本从两个文本文件制作一个文本文件

[英]How To Make One Text File From Two Text files Text With Apple Script

我正在尝试以某种特定方式将两个文本文件合并为一个文本文件。 我有很多文本文件,所以我想自动执行此过程。 我试图为此学习苹果脚本。

如何使用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
}

这种文件输出

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

要么

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM