Michael Giardina
asked on
Using batch, take specific numbers in a text file and sum them before writing the results back to the same txt file.
I'd like to use a batch file to sum some specific numbers in a text file, unfortunately I do not have the skills required. In the following text file "test.txt", for all rows beginning with "622..." I need the second block of numbers summed together and put in a line after the last "622..." line. The total must retain any leading zeros so that the result will always be 15 digits long. It should also line up with the spacing of the values above it. The first number in the total line is a constant, as is the “COMPANY NAME”. At the end of this total line, the “00724…” number should maintain the chronological order of the one above it.
Original txt file:
Example:
Any help at all with this would be greatly appreciated!
Original txt file:
101 123456789123456789123456789123456789BANK NAME COMPANY NAME
5200COMPANY NAME 1234567891CCDPAYMENT 123456789123 1072414250000001
62202123456789123456789 000056998811365 CHEMICAL MASTER LTD 0072414250000001
622021321321456987568 000149897016984 CHEMCO USA INC 0072414250000002
622011233214569874563211 000017285016585 GUME INC 0072414250000003
6220225411123658954212 000270139112936 DIOVIK GROUP 0072414250000004
6220432211655548541232 000000632017155 SANVED ENTERPRISES 0072414250000005
820000000500112340500000000000000000497895191123456789 072414250000001
900000100000100000001234732205000000000000000004949519
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
Example:
101 123456789123456789123456789123456789BANK NAME COMPANY NAME
5200COMPANY NAME 1234567891CCDPAYMENT 123456789123 1072414250000001
62202123456789123456789 000056998811365 CHEMICAL MASTER LTD 0072414250000001
622021321321456987568 000149897016984 CHEMCO USA INC 0072414250000002
622011233214569874563211 000017285016585 GUME INC 0072414250000003
6220225411123658954212 000270139112936 DIOVIK GROUP 0072414250000004
6220432211655548541232 000000632017155 SANVED ENTERPRISES 0072414250000005
6270154235698742245482 000494951975025 COMPANY NAME 0072414250000006
820000000500112340500000000000000000497895191123456789 072414250000001
900000100000100000001234732205000000000000000004949519
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
Any help at all with this would be greatly appreciated!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
EXPERT CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much!