简体   繁体   English

批处理:将一个txt文件的内容复制到另一个

[英]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.

相关问题 批处理文件,仅将每个子文件夹的文件类型之一复制到另一个文件夹 - batch file to copy only one of filetype for each subfolder to another folder 如何使用批处理脚本根据.txt文件内容将文件复制到不同的地方 - How to copy files to different places based on .txt file content with batch script 将元数据从一个文件批量复制到另一个文件(EXIFTOOL) - Batch copy metadata from one file to another (EXIFTOOL) 批处理文件可将文件从一个目录复制到另一个目录 - Batch file to copy files from one directory to another 如何在批处理文件中将选定的文件从一个文件夹复制到另一个文件夹? - How to copy selected files from one folder to another in Batch file? 批处理从.txt复制文件名列表并生成另一个.txt - batch that copy list of filesnames from a .txt and generate another .txt 在 CMD 中将内容从一个文件复制到另一个文件 - Copy Content From One File to Another File in CMD 批量> file.txt到一个文件 - Batch > file.txt to one file 批处理文件以搜索文件名并将其复制到新的TXT文件中 - Batch file to search and copy file names to new TXT file 如何使用批处理脚本将前15个txt文件从c驱动器中的一个文件夹复制到c驱动器中的另一个文件夹? - How to copy top 15 txt files from one folder in c drive to another folder in c drive using batch script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM