Merge, Copy on Dos batch file

October 13, 2009 at 11:20:16
Specs: Windows XP
Hi, I'm looking for help how to merge or copy all CSV files without the first row 'header'. I want this on Dos command (*.bat) file if possible.
So csv look like:
cvs1:
A,B,C,D
1,2,3,4
csv2:
A,B,C,D
5,6,7,8

result i want is:
all.cvs:
A, B, C, D
1, 2, 3, 4
5, 6, 7, 8
Thanks in advance!


See More: Merge, Copy on Dos batch file

Report •


#1
October 13, 2009 at 12:20:06
You would have better luck with a posting in the programming since this is not a xp issue.

Moderator please delete.


Report •

#2
October 13, 2009 at 14:25:59
Difficult at best in DOS. In XP try this:

==================================
@echo off & setLocal EnableDELAYedExpansion

if exist all.csv del all.csv
set /p head=<1.csv
> newfile echo !head!

for /f "tokens=* delims= " %%a in ('dir/b *.csv') do (
for /f "skip=1 tokens=* delims= " %%i in (%%a) do (
>> newfile echo %%i
)
)
ren newfile all.csv


=====================================
Helping others achieve escape felicity

M2


Report •

#3
October 13, 2009 at 15:33:27
Mechanix2go... I am sure your help is appreciated but there are forums devoted to various aspects of computing and it is better that posters use them. This forum is being beseiged by posters looking for help with batch, bat and other programming issues.

Home Page http://ewen.uuuq.com/


Report •

Related Solutions

#4
October 14, 2009 at 05:20:15
Thanks Mechanix2Go
U r the best! one thing missing is the header I want to keep the same header or column name for all CSV files.

i.e.
csv1:
A, B, C, D
1, 2, 3, 4

csv2:
A, B, C, D
5, 6, 7, 8


csv3:
A, B, C, D
11,12,13,


results should be:
all.csv:
A, B, C, D
1, 2, 3, 4
5, 6, 7, 8
11,12,13,


Report •

#5
October 14, 2009 at 05:46:25
When I run it I get the header.


=====================================
Helping others achieve escape felicity

M2


Report •

#6
October 14, 2009 at 05:59:33
I have another challenge task:

2 csv's with the same column contents just different name and I have another 2 csv's with the same columns...
i.e
abc_1.csv & def_1.csv --> results: abcdef.csv
gof_1.csv & yol_1.csv --> results: gofyol.csv

abc_1.csv contains:
A, B, C
1,2,3
def_1.csv contains:
A, B, C
4, 5, 6
results: abcdef.csv
A, B, C
1,2,3
4,5,6

gof_1.csv contains:
AA,BB,CC
11,22,33
yol_1.csv contains:
AA,BB,CC
44, 55, 66
results: gofyol.csv
AA, BB, CC
11,22,33
44,55,66

So basically, I want 1 batch script to do this instead.


Report •

#7
October 14, 2009 at 06:12:08
If it's going to do selective merging, as distinct from merging all CSVs in the folder, it will need to prompt for what to merge with what.

That's your homework assignment.


=====================================
Helping others achieve escape felicity

M2


Report •

#8
October 14, 2009 at 06:25:32
wow that's sound more complicated...any hint?

Report •


Ask Question