[英]Batch: copy content of one txt file into another
Hi this is what i want to do: 嗨,这是我想做的事:
I define a directory eg C:\\TEXT
. 我定义一个目录,例如
C:\\TEXT
。 If a txt
file is posted/generated/moved into that directory, it opens the txt
file copies its content, generates a new txt
file, pastes that content into the new file and deletes the old one, is that possible? 如果将
txt
文件发布/生成/移动到该目录中,它将打开该txt
文件复制其内容,生成一个新的txt
文件,将该内容粘贴到新文件中并删除旧文件,这可能吗?
It is fine if both txt
files have pre-defined names. 如果两个
txt
文件都具有预定义的名称,则可以。
Thanks a lot if anyone can help here! 非常感谢任何人可以在这里提供帮助!
You should be able to do something like: 您应该能够执行以下操作:
TYPE 1.TXT > FINAL.TXT
TYPE 2.TXT >> FINAL.TXT
Note: the ">" will over-write. 注意:“>”将被覆盖。 The ">>" will append or add to a file.
“ >>”将追加或添加到文件中。
Hope this helps! 希望这可以帮助!
The following will accomplish the same with Boxed headings for every text file or batch file depending on your choice. 对于每个文本文件或批处理文件,以下内容将根据带框标题完成相同的操作,具体取决于您的选择。 Simply change the *.txt to *.bat or any text based file and the output will have a boxed heading of the filename along with the actual text from inside.
只需将* .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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.