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

Concatenating files using Batch pro

Reply to Message Icon

Original Message
Name: ksuchetan
Date: July 15, 2008 at 10:23:19 Pacific
Subject: Concatenating files using Batch pro
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


Report Offensive Message For Removal

Response Number 1
Name: ksuchetan
Date: July 15, 2008 at 11:12:51 Pacific
Subject: Concatenating files using Batch pro
Reply: (edit)

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


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Concatenating files using Batch pro

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software