Click here to Skip to main content
15,664,506 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have two csv files in different folders and would like to merge them. I am using copy command in windows cmd but the first line from second file is getting appended to the last line of first file.
How do I start copying from new line.
COPY t1.csv + t2.csv result.csv

result.csv file is

hey this is t1hey this is t2

I want
hey this is t1
hey this is t2

What I have tried:

I have tried using /r/n but no use.
Updated 9-Jun-16 3:59am
ZurdoDev 8-Jun-16 14:56pm    
How did you try to use r/n?
Member 12573208 8-Jun-16 15:07pm    
COPY t1.csv +/r/n + t2.csv result.csv
Sergey Alexandrovich Kryukov 8-Jun-16 15:12pm    
Using copy and/or cmd.exe is not a programming question. Sorry, this is off-topic.
If this is just two file, what preventing you from manually adding an empty line in the first file at the end?

If you want to use many files in the batch, there are many solutions around, like

Sergey Alexandrovich Kryukov 8-Jun-16 15:14pm    
Here is one user-level soluton for you. Create a file with empty line; say, it's name is 1-line.txt.
Use copy t1.csv + 1-line.txt + t2.sdv + 1-line.txt + t2.txt
And so on...

I did not post formal answers only because this is off-topic and low-tech...

Member 12573208 8-Jun-16 15:40pm    
I am looking for a command line keyword not a work around. but thanks anyways.

1 solution

Despite the fact this is off-topic, I'm going to give this a formal solution just to get it out of the list of Unanswered Questions.

If you insist on doing this in a cmd window then you have 2 options.

1. Follow the advice given by Sergey... Either have a buffer file to include in the COPY command or use the technique provided on the link.

2. Use TYPE instead of COPY (which is actually used on the link in SA's comment)
TYPE t1.csv > t3.csv
ECHO. >> t3.csv
TYPE t2.csv >> t3.csv

Alternatives have already been mentioned by Richard - use Copy+Paste in something like Notepad, or use Excel to load the data.
If this is going to happen often then write a program to merge the text from the files.
Share this answer
Patrice T 9-Jun-16 14:53pm    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900