Computing.Net > Forums > Windows XP > Merge, Copy on Dos batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Merge, Copy on Dos batch file

Reply to Message Icon

Name: leeuy73
Date: October 13, 2009 at 11:20:16 Pacific
OS: Windows XP
Subcategory: General
Comment:

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!



Sponsored Link
Ads by Google

Response Number 1
Name: wanderer
Date: October 13, 2009 at 12:20:06 Pacific
Reply:

You would have better luck with a posting in the programming since this is not a xp issue.

Moderator please delete.


0

Response Number 2
Name: Mechanix2Go
Date: October 13, 2009 at 14:25:59 Pacific
Reply:

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


0

Response Number 3
Name: Ewen
Date: October 13, 2009 at 15:33:27 Pacific
Reply:

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/


0

Response Number 4
Name: leeuy73
Date: October 14, 2009 at 05:20:15 Pacific
Reply:

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,


0

Response Number 5
Name: Mechanix2Go
Date: October 14, 2009 at 05:46:25 Pacific
Reply:

When I run it I get the header.


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

M2


0

Related Posts

See More



Response Number 6
Name: leeuy73
Date: October 14, 2009 at 05:59:33 Pacific
Reply:

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.


0

Response Number 7
Name: Mechanix2Go
Date: October 14, 2009 at 06:12:08 Pacific
Reply:

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


0

Response Number 8
Name: leeuy73
Date: October 14, 2009 at 06:25:32 Pacific
Reply:

wow that's sound more complicated...any hint?


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Merge, Copy on Dos batch file

dos batch file silent windows xp www.computing.net/answers/windows-xp/dos-batch-file-silent-windows-xp/139313.html

Cannot Open MS-DOS Batch File www.computing.net/answers/windows-xp/cannot-open-msdos-batch-file/112694.html

DOS Batch File Parameters with Zero www.computing.net/answers/windows-xp/dos-batch-file-parameters-with-zero/170211.html