Computing.Net > Forums > Programming > Concatenating files using Batch pro

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.

Concatenating files using Batch pro

Reply to Message Icon

Name: ksuchetan
Date: July 15, 2008 at 10:23:19 Pacific
OS: winxp
CPU/Ram: 2 gb
Comment:

Hi,

I want to write a batch program to concatenate the number of files in Folder A (The number of files in Folder A may vary)

The suppose file 1 looks is:

Name Addr State Country
A B NJ US
C D CA US

File2 is

Name Addr State Country
E F NJ US
G H CA US

The desired Output file should look like


Name Addr State Country
A B NJ US
C D CA US
E F NJ US
G H CA US


I am new to batch programming Please need help with this.

I understand copy command can be used to do this but the file name is
200807test.txt thenother file name will be 200809test.txt i.e. yyyymmtest.txt


Thanks In Advance

Thanks In Advance



Sponsored Link
Ads by Google

Response Number 1
Name: ksuchetan
Date: July 15, 2008 at 11:12:51 Pacific
Reply:

Folder A may contain two files today but tommorow it may contain 3 or more files help me with this .

The approach I am following is first

calculate the number of files in the folder:

echo off
set count=0
CD%1

FOR %%i in (*%2) do set /A count+=1
cd ..
echo %count%


then I want to strip off the first line of each and then concatenate.

the code for stripping the header is :

for /f "tokens=* skip=1" %%A in (%1) do ( echo %%A >> newfile-firstline-deleted.txt )

this works for one file I want to make it work for all the files in the folder as %1 would be the common text for the file name

can you please help me with this

Thanks In Advance


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Concatenating files using Batch pro

Editing a Hex file using a Batch script www.computing.net/answers/programming/editing-a-hex-file-using-a-batch-script/19381.html

renaming files using .bat file www.computing.net/answers/programming/renaming-files-using-bat-file/17633.html

get 3rd line frm EOFof txt file by batch www.computing.net/answers/programming/get-3rd-line-frm-eofof-txt-file-by-batch-/19022.html