I am trying to take a folder that has several .csv files in it and combine all of these files and the information in them, into one file using MS DOS. Any suggestions?
If there are multiple files you want to merge at the same time, you can select multiple files by holding down the Ctrl and selecting each file you want to merge.
copy *.csv new.csv
No need for /b as csv isn't a binary file type.
copy /b file1 + file2 + file3 newfile
Each source file must be added to the copy command with a +
, and the last filename listed will be where the concatenated data is copied to.
If this is part of a batch script (.bat
file) and you have a large list of files, you can use a multi-line ^
, and optional /Y
flag to suppresses prompting to confirm you want to overwrite an existing destination file.
REM Concatenate several files to one
COPY /Y ^
this_is_file_1.csv + ^
this_is_file_2.csv + ^
this_is_file_3.csv + ^
this_is_file_4.csv + ^
this_is_file_5.csv + ^
this_is_file_6.csv + ^
this_is_file_7.csv + ^
this_is_file_8.csv + ^
this_is_file_9.csv ^
output_file.csv
This is tidier than performing the command on one line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With