get the data from multiple text in Zip file
Moderator: DosItHelp
get the data from multiple text in Zip file
Hi,
I have multiple zip file date wise in folder (like- 01072012.zip..02072012.zip..03072012.zip ) in which there is one text file with same file name in all zip file( cr09.txt ).if i exact all zip file in folder due to same file name in all zip file its got override.
i want bat file which give me particular row start with TOTAL form each text file (cr09.txt) from all zip files in separate file with file name summary.txt in same folder.
i got the below code by foxidrive but this apply only all txt file in folder.
@echo off
findstr /i "^TOTAL:" *.txt >summary.txt
Requred result as below
file name total
01072012.zip Total :
Pls help
I have multiple zip file date wise in folder (like- 01072012.zip..02072012.zip..03072012.zip ) in which there is one text file with same file name in all zip file( cr09.txt ).if i exact all zip file in folder due to same file name in all zip file its got override.
i want bat file which give me particular row start with TOTAL form each text file (cr09.txt) from all zip files in separate file with file name summary.txt in same folder.
i got the below code by foxidrive but this apply only all txt file in folder.
@echo off
findstr /i "^TOTAL:" *.txt >summary.txt
Requred result as below
file name total
01072012.zip Total :
Pls help
Re: get the data from multiple text in Zip file
This should be a start. It requires UNZIP.EXE or another program to unzip the ZIP files.
Code: Select all
@echo off
for %%a in (*.zip) do (
del cr09.txt 2>nul
unzip "%%a"
findstr /i /s "^TOTAL:" cr09.txt >>summary.txt
del cr09.txt 2>nul
)
Re: get the data from multiple text in Zip file
Sir,
Thanks for your prompt reply.. have copy unzip.exe in folder but its showing
"Archive: 1.zip
replace1/cr09.txt? ( y-yes),(N-no),(A-all),(R-rename): "
for each file
Thanks for your prompt reply.. have copy unzip.exe in folder but its showing
"Archive: 1.zip
replace1/cr09.txt? ( y-yes),(N-no),(A-all),(R-rename): "
for each file
Re: get the data from multiple text in Zip file
It seems to be creating directories, so try the following with the switches in unzip.
Code: Select all
@echo off
for %%a in (*.zip) do (
del cr09.txt 2>nul
unzip -jo "%%a"
findstr /i /s "^TOTAL:" cr09.txt >>summary.txt
del cr09.txt 2>nul
)
Re: get the data from multiple text in Zip file
Sir,
not asking for replace file now. but its create only summary file ( 0 kb) without any data.
not geting any data from txt file.
not asking for replace file now. but its create only summary file ( 0 kb) without any data.
not geting any data from txt file.
Re: get the data from multiple text in Zip file
Two things have to be checked.
A) that there is a cr09.txt file in the zip file
B) that it contains TOTAL: in the first column.
Try this version and when it pauses, don't press a key but examine the folder for a cr09.txt file and check the contents.
Then you can press a key and check the next file in the same way.
Before the pause it should list the text files in the folder for you.
A) that there is a cr09.txt file in the zip file
B) that it contains TOTAL: in the first column.
Try this version and when it pauses, don't press a key but examine the folder for a cr09.txt file and check the contents.
Then you can press a key and check the next file in the same way.
Before the pause it should list the text files in the folder for you.
Code: Select all
@echo off
for %%a in (*.zip) do (
del cr09.txt 2>nul
unzip -jo "%%a"
dir *.txt
pause
findstr /i /s "^TOTAL:" cr09.txt >>summary.txt
del cr09.txt 2>nul
)
Re: get the data from multiple text in Zip file
Sir,
still not work,
A) that there is a cr09.txt file in the zip file
: in zip file there is folder in which cr09.txt file exist.
B) that it contains TOTAL: in the first column.
: i think contains TOTAL: is not in first column., copy raw from cr09.txt below for your ref.
TOTAL: start from column 8.
TOTAL: 5 15,85,600.70 1,268 81,31,473.81
still not work,
A) that there is a cr09.txt file in the zip file
: in zip file there is folder in which cr09.txt file exist.
B) that it contains TOTAL: in the first column.
: i think contains TOTAL: is not in first column., copy raw from cr09.txt below for your ref.
TOTAL: start from column 8.
TOTAL: 5 15,85,600.70 1,268 81,31,473.81
Re: get the data from multiple text in Zip file
Try this. It now looks for Total: in any column.
Code: Select all
@echo off
for %%a in (*.zip) do (
del cr09.txt 2>nul
unzip -jo "%%a"
findstr /i /s "TOTAL:" cr09.txt >>summary.txt
del cr09.txt 2>nul
)
Re: get the data from multiple text in Zip file
YES!! perfect.. its work..
Thanks a lot
.
But as I mentioned in my first post. is it possible to get zip file name in summary instead of CR09.TXT.
In output file getting below data which i required. but due to same file name in all zip file it won't give me date which is mentioned in zip file name.
zip file name will be date wise like ( 01072012.zip, 02072012.zip, 03072012.zip.... )required zip file name and total of cr09.txt of that perticuler zip file in summary.
Thank u once again ...
CR09.TXT: TOTAL: 3
CR09.TXT: TOTAL: 4
CR09.TXT: TOTAL: 5
CR09.TXT: TOTAL: 6
CR09.TXT: TOTAL: 7
CR09.TXT: TOTAL: 8
CR09.TXT: TOTAL: 9
CR09.TXT: TOTAL: 10
Thanks a lot

But as I mentioned in my first post. is it possible to get zip file name in summary instead of CR09.TXT.
In output file getting below data which i required. but due to same file name in all zip file it won't give me date which is mentioned in zip file name.
zip file name will be date wise like ( 01072012.zip, 02072012.zip, 03072012.zip.... )required zip file name and total of cr09.txt of that perticuler zip file in summary.
Thank u once again ...
CR09.TXT: TOTAL: 3
CR09.TXT: TOTAL: 4
CR09.TXT: TOTAL: 5
CR09.TXT: TOTAL: 6
CR09.TXT: TOTAL: 7
CR09.TXT: TOTAL: 8
CR09.TXT: TOTAL: 9
CR09.TXT: TOTAL: 10
Re: get the data from multiple text in Zip file
Try this:
Code: Select all
@echo off
for %%a in (*.zip) do (
del cr09.txt 2>nul
unzip -jo "%%a"
for /f "delims=" %%b in ('findstr /i "TOTAL:" cr09.txt') do >>summary.txt echo %%a: %%b
del cr09.txt 2>nul
)
Re: get the data from multiple text in Zip file
Sir,
perfect what i want....u r simply the greee8..many thanks .
perfect what i want....u r simply the greee8..many thanks .