批量:将一个txt文件的内容复制到另一个
Batch: copy content of one txt file into another
嗨,这是我想做的:
我定义了一个目录,例如C:\TEXT
。
如果 txt
文件是 posted/generated/moved 到该目录,它会打开 txt
文件复制其内容,生成一个新的 txt
文件,将该内容粘贴到新文件中并删除旧的,可以吗?
如果两个 txt
文件都有预定义的名称就可以了。
如果有人能在这里提供帮助,非常感谢!
您应该可以执行以下操作:
TYPE 1.TXT > FINAL.TXT
TYPE 2.TXT >> FINAL.TXT
注意:“>”会覆盖。 “>>”将追加或添加到文件。
希望对您有所帮助!
以下将根据您的选择对每个文本文件或批处理文件的带框标题完成相同的操作。只需将 *.txt 更改为 *.bat 或任何基于文本的文件,输出将有一个带框的文件名标题以及内部的实际文本。
@echo off
::If the file "Allbatchfiles.txt exists in the running folder then delete it.
IF EXIST Allbatchfiles.txt (
del Allbatchfiles.txt
)
:: For every file with the ".bat" extention Make an entry with
:: a Boxed heading of the filename and the contents of the file
:: and output to the file Allbatchfiles.txt
for %%f in (*.bat) do echo. >>AllBatchfiles.txt && echo ============================================ >>AllBatchfiles.txt && echo ----------"%%f"---------- >> AllBatchfiles.txt && echo ============================================ >>AllBatchfiles.txt && type "%%f" >>AllBatchfiles.txt
嗨,这是我想做的:
我定义了一个目录,例如C:\TEXT
。
如果 txt
文件是 posted/generated/moved 到该目录,它会打开 txt
文件复制其内容,生成一个新的 txt
文件,将该内容粘贴到新文件中并删除旧的,可以吗?
如果两个 txt
文件都有预定义的名称就可以了。
如果有人能在这里提供帮助,非常感谢!
您应该可以执行以下操作:
TYPE 1.TXT > FINAL.TXT
TYPE 2.TXT >> FINAL.TXT
注意:“>”会覆盖。 “>>”将追加或添加到文件。
希望对您有所帮助!
以下将根据您的选择对每个文本文件或批处理文件的带框标题完成相同的操作。只需将 *.txt 更改为 *.bat 或任何基于文本的文件,输出将有一个带框的文件名标题以及内部的实际文本。
@echo off
::If the file "Allbatchfiles.txt exists in the running folder then delete it.
IF EXIST Allbatchfiles.txt (
del Allbatchfiles.txt
)
:: For every file with the ".bat" extention Make an entry with
:: a Boxed heading of the filename and the contents of the file
:: and output to the file Allbatchfiles.txt
for %%f in (*.bat) do echo. >>AllBatchfiles.txt && echo ============================================ >>AllBatchfiles.txt && echo ----------"%%f"---------- >> AllBatchfiles.txt && echo ============================================ >>AllBatchfiles.txt && type "%%f" >>AllBatchfiles.txt