How do I append to a file using the COPY command How do I append to a file using the COPY command windows windows

How do I append to a file using the COPY command


Windows 8 x86:

Microsoft Windows [Version 6.2.9200](c) 2012 Microsoft Corporation. All rights reserved.C:\Users\Nikos>echo foo>file1C:\Users\Nikos>echo bar>file2C:\Users\Nikos>copy /b file1 + file2 file1file1file2        1 file(s) copied.C:\Users\Nikos>type file1foobar


Answer to: "How do I append to a file using the COPY command"

WARNING: If you have a list of files you wish to combine via COPY command, it's simple but can potentially destroy your files.

Dangerous Way:

copy /b one + two + three -- will append contents of "two" and "three" to the file "one" . So the original "one" now has contents of 3 files in proper sequence. If during copy-process things go wrong, you'll have no way of recovering original "one", as it will be corrupt and your data would essentially be lost. There's almost Never a reason to use this way.

Safe Way:

copy /b one + two new_filename -- will combine 2 files (you can list more than two of course), creating a new_filename containing "one" and "two" in proper sequence, and leaving original files intact.