How do I append to a file using the COPY command

dos command append to text file
append text to file windows command line
windows command line copy concatenate files
batch file append to text file
dos concatenate files with new line
dos copy command
xcopy append files
which command is used to copy files

I'm running Windows 7 Ultimate x64, but my experience dates back to DOS 3.0.

Since like DOS 3.1 you've been able to append a file to another one with this use of the COPY command:


Making the need for a temporary FILE3 unnecessary.

It was a very convenient command since whenever you added a new program you often needed to update your CONFIG.SYS and AUTOEXEC.BAT files.

It also used to be that getting the order correct was importiant, otherwise you'd end up with an empty FILE1.

But today when I tried that, it left FILE1 untouched, and when I reversed the order, it (understandably) made FILE1 a copy of FILE2.

Does anyone know if it's been replaced with another method, and when this change happened?


I've been doing more testing, and oddly even though the above code won't work, you still can sill copy from the console and append that to an existing file like this:

copy file1+con=file1
Type some text to append to file1
^Z ([CTRL]+Z the End Of File character)

I'm wondering if my version of Windows is messed up somehow. Can any body replicate my findings?


It works on 95 / 98 / ME / 2000 / XP / XP Mode / 7 Professional x64 / 8 x64. So I imagine that it's not a 7 Ultimate x64 problem, but rather an issue with my machine.

* Sigh *


Last edit, I promise. :)

It was not an issue with my machine, it was an issue with File1. Apparently when I first appended File2 to it, the [CTRL]+Z (EOF character) never got overwritten, causing the file to look like this:

Original Data
Original Data
Appended Data
Appended Data
Appended Data

You can duplicate this yourself with the following experiment from at the command prompt. (Where ^Z is the character [CTRL]+Z )

At the command prompt type:

copy con file1
File One

copy con file2
File Two

copy con file3
File Three

copy file1+file2=file1

copy file2+file3=file2

TYPE file1
TYPE file2

You will see:


File One


File Two
File Three

You can type file2 >> file1 or use nearly any other method of concatenating files, and when you type file1 it will still only appear to contain File One. BUT if you use FIND "searchterm" file to parse the file it will show you what's REALLY going on. In this case type:

FIND " " file1

And you will be rewarded with:

---------- FILE1
File One
→File Two

Windows 8 x86:

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Nikos>echo foo>file1

C:\Users\Nikos>echo bar>file2

C:\Users\Nikos>copy /b file1 + file2 file1
        1 file(s) copied.

C:\Users\Nikos>type file1

How to append output to the end of a text file, How can you append the output of a command to a file? The switch /Y may be preset in the COPYCMD environment variable. This setting may be overridden with /-Y on the command line. To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).

What about type file2 >> file1

Appending one file to another, , use the >> redirection operator or the tee command. By default, you are prompted when you replace this setting, unless the copy command is executed in a batch script. To append files, specify a single file for destination, but multiple files for source (use wildcard characters or file1 + file2 + file3 format).

make sure you start with fresh files you never tried to copy over. I just found that on my (XP sp3) copy a+b a without /b appends 1A (SUB) to the end of the file which makes anything after it disappear from output of type (but more will show it). Copy /b a+b a works.

Bash: Append to File, guides the search for data files (such as text files). Use the copy Windows command line to append multiple files together. See our copy command page for examples and additional information. How can I append text into a file in the Windows command line? Using the echo command, you can append any text to a file.

@echo off


type "file2.txt" >> "file1.txt"


DOS Command, Using the DOS copy command syntax to concatenate files: copy file1.txt+file2.txt all.txt. I know I can do this copy file1.txt+file2.txt file1.txt. Is this efficient? How to Copy Files in Command Prompt. This wikiHow teaches you how to use Windows' Command Prompt program to copy a file or folder. Find out your file's location. You'll need the file's location—also known as a "directory"—in order to tell C

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.

Is there a way to append files efficiently using the DOS copy , For example, to append a file called report2 to the end of report1, type: cat report2 >> report1. You can use the append symbol ``>>'' with any command that​  You can also add data to other config files. Another option is to run command and append output to a file. Run data command at the terminal and append output to output.txt: date >> output.txt Execute ls command and append data to files.txt: ls >> files.txt To see files.txt use cat command: cat files.txt more files.txt less files.txt

copy files and append in another directory?, But before using pattern-matching to execute commands like this I would run a couple of sanity-check commands to verify which files will be  The APPEND command is new to DOS with Versions 3.3 and later. It gives you a way to set the search path for data files. The APPEND command is similar to the PATH command that tells DOS where to search for program files (files with a .COM, .EXE, or .BAT filename extension). The APPEND command guides the search for data files (such as text files

Append the contents of one text file to the end of another text file., Help files indicate the COPY command will append my files together with the "+" function. I have had no success with this command either. Execute the following command, (change the file path) Add-Content c:\scripts\test.txt "The End" By default, data is appended after the last character. If you want to append the data on a new line in the text document, use 'n. are some other special characters that can be used with add-content cmdlet. Here are some other special characters that

Windows Administration at the Command Line for Windows Vista, , Executing Append with just a semicolon clears all of the appended paths for a Copying Files with the Copy Command The Copy command lets you create a  RELATED: 10 Ways to Open the Command Prompt in Windows 10. To copy a file, you can use the following command syntax (if you’re copying a folder, just omit the file extension): copy "file name.ext" "full\path\to\destination\folder" The quotes in the command are only important when the file name or folder contains spaces.

  • what do you get when copying foo+bar=foo?
  • I get the original version of foo.
  • I have verified that copy file1+file2=file1 works on Windows 7 Professional x64, so I believe that it's probably my machine.
  • Thanks for helping me figure this out. :)
  • Is there any way to retrieve file2 and file1 again using command??
  • @JamesK You never stated "binary" in your question. What exactly do you want to do then?
  • @EitanT - I'm just wondering if that functionality has disappeared from windows because it's more efficient than any other built-in method of concatenation of files, binary OR text.
  • Actually, that doesn't work either. The problem is that the file got two EOF characters at the end of it, so when appending using almost any method, one EOF character survives with the appended text coming after it.
  • Yes, I was able to confirm that it works on XP. Well, XP Mode anyway.
  • For me, this is best solution so far. I want to append one text file to another. This is easiest method: copy destin_file new_file appends new_file onto destin_file
  • @DougNull That will not work actually. If you only have 2 files like this: copy File_1 File2 what will happen is copy will not do appending it will create a copy of File1 and name it File2. If File2 exists it will overwrite it. I updated my answer to the two-file scenario
  • Yes. I've tried every iteration I can think of and every one I've run across.
  • Sure, even copy /b file1 + file2 file3 move file3 file1 works. I'm not trying to replace the functionality, I'm trying to discover if it's been removed from the COPY command (and when), or if my computer is messed up.