summary from multiple text files in folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
DingDang
Posts: 26
Joined: 06 Jul 2012 11:04

summary from multiple text files in folder

#1 Post by DingDang » 06 Jul 2012 11:20

I have multiple text files in folder in which there is row start from "Total"
I want batch file which get all row of file start from Total in one file also start from file name
e.g
file name in folder c:\text\ file name 1.txt, 2.txt,3.txt.....so on

result required in seprate file which auto save as summary.txt in same foleder.

file name total
1.txt 12121.00
2.txt 23232.00
3.txt 454545.00

Pls help

Aacini
Expert
Posts: 1932
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: summary from multiple text files in folder

#2 Post by Aacini » 06 Jul 2012 17:36

Code: Select all

@echo off
( for %%a in (*.txt) do (
   for /F "tokens=2" %%b in ('findstr "Total" "%%a"') do echo %%a  %%b
) ) > summary.tmp
ren summary.tmp summary.txt

DingDang
Posts: 26
Joined: 06 Jul 2012 11:04

Re: summary from multiple text files in folder

#3 Post by DingDang » 08 Jul 2012 09:40

Gre8..Thanks a lot for code.

but, one more help required in summary file entire row not copying. txt file contain below data which start from Total.

TOTAL: 71 15,74,786.00 97 1,14,06,129.35
TOTAL: 3 15,80,696.70 1,262 81,31,483.87

it should copy entire row. pls help
requried details in summary file should as below

1.txt TOTAL: 71 15,74,786.00 97 1,14,06,129.35
2.TXT TOTAL: 3 15,80,696.70 1,262 81,31,483.87

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: summary from multiple text files in folder

#4 Post by foxidrive » 08 Jul 2012 11:41

This returns the text below it. Is that any good?

Code: Select all

@echo off
findstr /i "^TOTAL:" *.txt >summary.txt


1.txt:TOTAL: 71 15,74,786.00 97 1,14,06,129.35
2.txt:TOTAL: 3 15,80,696.70 1,262 81,31,483.87

DingDang
Posts: 26
Joined: 06 Jul 2012 11:04

Re: summary from multiple text files in folder

#5 Post by DingDang » 09 Jul 2012 10:08

Dear foxidrive.

u r simply the great...its work.

Thanks a lot. :)

Post Reply