Merging order for two text files in batch

November 20, 2010 at 14:13:39
Specs: Windows 7

I do not know batch two well, and something weird is happening while I am trying to add the same header to multiple files.
I use a loop, where the main command is:
copy /b "header.csv" + "!file%count%!.csv" "!file%count%!.csv"

When I use this, the new file contain ONLY the header!
And when I reverse the order ( "!file%count%!.csv"+"chinaheader.csv" ), I have a merging but the header is in the last row...

Does anyone know whats wrong?

Thank you in advance for your help!

See More: Merging order for two text files in batch

Report •

November 20, 2010 at 15:29:20
Unfortunately, you can't insert a header in front of an existing file (though, as you've discovered, you can append a trailer at the end of a file.)

You need to write to a file using a temporary name, delete the existing file, and rename the temporary file name to the file name you want.

Report •

November 20, 2010 at 16:44:38
TYPE "header.csv">#
TYPE !file%count%!>>#
REN "#" "!file%count%!"

Can I put a question here?

Report •

November 20, 2010 at 21:41:49
Thank you Matt and klint!

I have used the lines from Matt.
Just had to put a different name for the new file (I added a letter before and removed this first character off all files names with Space tornato Renamer).
Otherwise, with what you wrote Matt, I think there was problem of duplicates...

Anyway, thank you again for your help!

Report •

Related Solutions

Ask Question