Need to reset the count to zero in batch after each address
Moderator: DosItHelp
Need to reset the count to zero in batch after each address
How do I reset the variable %%a back to zero after it adds, so when it reaches the next line and the find variable %%a it will give a correct count.
When it finds the first address I want it to execute two more finds to give me a total for Request -DCC and Clean Request -DCC for that location, then drop down to another address and do two more finds giving a new count for Request -DCC and Clean Request -DCC.
Code:
type "MultiProperties06-09.txt" | find " 8550 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Clean Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Clean Request - DCC>>"Updated Properties.xls" )
type "MultiProperties06-09.txt" | find " 9850 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Clean Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Clean Request - DCC>>"Updated Properties.xls" )
Thank you for your help
Ken
When it finds the first address I want it to execute two more finds to give me a total for Request -DCC and Clean Request -DCC for that location, then drop down to another address and do two more finds giving a new count for Request -DCC and Clean Request -DCC.
Code:
type "MultiProperties06-09.txt" | find " 8550 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Clean Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Clean Request - DCC>>"Updated Properties.xls" )
type "MultiProperties06-09.txt" | find " 9850 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Clean Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Clean Request - DCC>>"Updated Properties.xls" )
Thank you for your help
Ken
Last edited by Ken on 14 Dec 2009 21:24, edited 1 time in total.
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
I want it to reset the count after each address
avery_larry,
I want it to reset the count after each address, right now it counts all the Request - DCC and Clean Request - DCC in the entire file.
Example of current output:
Request - DCC = 1205 (for every location)
Clean Request - DCC = 1487 (for every location)
If it is reset to zero after each location I will get a correct total.
Example if I have a location at 8550 N CENTRAL ACRD that have the following (2 Request - DCC) and (5 Clean Request - DCC)
I would like it to total the following: Request - DCC = 2
Clean Request = DCC = 5
Total count for Location = 7
Then when it reads the next address 9850 N CENTRAL ACRD that have the following (6 Request - DCC) and (5 Clean Request - DCC)
I would like it to total the following: Request - DCC = 6
Clean Request = DCC = 5
Total count for Location = 11
Thank you for looking at the code
Ken
I want it to reset the count after each address, right now it counts all the Request - DCC and Clean Request - DCC in the entire file.
Example of current output:
Request - DCC = 1205 (for every location)
Clean Request - DCC = 1487 (for every location)
If it is reset to zero after each location I will get a correct total.
Example if I have a location at 8550 N CENTRAL ACRD that have the following (2 Request - DCC) and (5 Clean Request - DCC)
I would like it to total the following: Request - DCC = 2
Clean Request = DCC = 5
Total count for Location = 7
Then when it reads the next address 9850 N CENTRAL ACRD that have the following (6 Request - DCC) and (5 Clean Request - DCC)
I would like it to total the following: Request - DCC = 6
Clean Request = DCC = 5
Total count for Location = 11
Thank you for looking at the code
Ken
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
So you have 1 big file, and then individual portions of the file you want treated separately?
That's a lot of work. You have to go line by line through it, keeping track of what part of the file you're in, and establish multiple variables that increment when you find the string, and finally put it all together after you've gone through the entire file.
That's a lot of work. You have to go line by line through it, keeping track of what part of the file you're in, and establish multiple variables that increment when you find the string, and finally put it all together after you've gone through the entire file.
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
avery_larry
Thank you for you help... This is the type of data I am looking at when running my batch file although there is many more addresses.
09-00161921 Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161944 Clean Request - DCC 9850 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
Thanks
Ken
Thank you for you help... This is the type of data I am looking at when running my batch file although there is many more addresses.
09-00161921 Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161944 Clean Request - DCC 9850 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
Thanks
Ken
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
If EVERY LINE has the address you're interested in, then you can use a double find command:
type "MultiProperties06-09.txt" | find " 8550 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find " 8550 N CENTRAL ACRD " "MultiProperties06-09.txt"| find /C "Request - DCC" ') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
So the find /c command which actually does the counting will only have the results of the find "property" command.
type "MultiProperties06-09.txt" | find " 8550 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find " 8550 N CENTRAL ACRD " "MultiProperties06-09.txt"| find /C "Request - DCC" ') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
So the find /c command which actually does the counting will only have the results of the find "property" command.
avery_larry
Thank you for the code but it is still not giving me what I need.
With your code and a second find added for "Clean Request - DCC"
This is what the output looks like.
09-00161921 Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161928 Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161960 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161965 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161972 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161986 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161994 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
I am trying to get it with the totals at the bottom after each address.
Location has Request - DCC = 2
Location has Clean Request = DCC = 5
Total count for Location = 7
Then when it reads the next address it will show a new count.
Code Used:
type "MultiProperties06-09.txt" | find " 8550 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find " 8550 N CENTRAL ACRD " "MultiProperties06-09.txt"| find /C "Request - DCC" ') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
find /C "Clean Request - DCC" ') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
Thank you for all your help
Ken
Thank you for the code but it is still not giving me what I need.
With your code and a second find added for "Clean Request - DCC"
This is what the output looks like.
09-00161921 Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161928 Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161960 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161965 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161972 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161986 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161994 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
I am trying to get it with the totals at the bottom after each address.
Location has Request - DCC = 2
Location has Clean Request = DCC = 5
Total count for Location = 7
Then when it reads the next address it will show a new count.
Code Used:
type "MultiProperties06-09.txt" | find " 8550 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find " 8550 N CENTRAL ACRD " "MultiProperties06-09.txt"| find /C "Request - DCC" ') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
find /C "Clean Request - DCC" ') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
Thank you for all your help
Ken
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa