batch file to serch for string copy andto txt

May 9, 2011 at 03:16:55
Specs: Windows XP
Please assist with the batch file that can search for a string that contain any of the key variables e.g 0001,0002,0003 and 0004. When the string with the key variable is found, then write the whole string to a new text file as a report.

Text file contents are as below.

5674223234376000443538
3432423000123554353455

Then output text file is formatted as
| AMOUNT | QTY | COLORS | REASON CODE | TAIL |
5674 22323 4376 0004 43538



See More: batch file to serch for string copy andto txt

Report •


#1
May 9, 2011 at 06:06:05
@echo off & setlocal EnableDelayedExpansion
echo.^| AMOUNT ^| QTY ^| COLORS ^| REASON CODE ^| TAIL ^|> FileOut.txt
for /F %%j in (FileIN.txt) do (
  set row=%%j
  if "!row:~13,3!"=="000" if "!row:~16,1!" leq "4" if "!row:~16,1!" geq "1" (
    set Amount=!row:~0,4!
    set Qty=!row:~4,5!
    set Colors=!row:~9,4!
    set RCode=!row:~13,4!
    set Tail=!row:~17,5!
    echo.!Amount! !Qty! !Colors! !RCode! !Tail!>> FileOut.txt
  )
)


Report •

#2
May 9, 2011 at 07:45:52
more details:

The files are in the directory as below: \\10.240.8.101\d$\BBAIN\BAK and listed as : 06090500.T66
06090500.T29
06090500.T28
06090500.T11
06090500.T20

The file contents are as below :

1850905201128000000050706031€00000000000000000000000000000000227200000000000000000000000000000000000000000000000000000000064400000000086800281400000057110000604010040025649706040000006340000000270460028140062267361849060101400202458010601000000

The report must look as bellow:

the first two digits from second are reason codes (64 and 63) and third and fourth are transaction types ( credit or debit)

file format :

batch_no | file_date | status | reason_code | reason


Report •

#3
May 9, 2011 at 12:47:33
Sorry, but now your issue is absolutely different from what you posted first time.

More it is absolutely obscure since it is not clear where the string is located inside each record and the record structure is unreadable to anyone not confident with your application. The output too is questionable: does it have a header and how are fields separated?

The genaral rule states "No exact info, no solution".


Report •

Related Solutions

#4
May 10, 2011 at 06:31:08
Different strings located at the begining of the line e.g 63 at 3rd row and copy whole line to new txt file as a report.

1850905201128000000050906041
2272000000000000000000000000
6340000000003730028126224923
1928000000000000000000000000


Report •

#5
May 10, 2011 at 08:27:49
So we have to select the lines starting with strings ???? and copy then to ONE report file. The files to be processed are named 06090500.Txx and stored in the reported directory (on an external computer). Strings (????) need to be explicited.

Please, confirm the above statements.


Report •

#6
May 11, 2011 at 03:10:01
The above statement is correct and the report need to be formated as below,

batch_no | file_date | status | reason_code | reason


Report •

#7
May 11, 2011 at 03:58:51
I am glad to give you the script, but

Specify the strings to be searched to select lines

Specify if you want a header

Specify if you need spaces as field separators in the report

Specify the layout of the input lines as it is not readable from your post #2

If you are more rich of exact info you just got the solution; sorry my ESP powers are limited.


Report •

#8
May 11, 2011 at 05:24:40
Specify the strings to be searched to select lines: the 63 at the 3rd line is reason code.

At 1st line 185 is sequance, 09052011 is date, 28 bank code e.g barclays

Therefore a file with 2272 in 2nd line , denotes is unpaids file. then search for the string e.g 63 to denote ACCOUNT STOPPED.

where 63 or any reason code is found, read the whole string and output the report. Tokernize with space.

1850905201128000000050906041000000000000000000000000000000000
2272000000000000000000000000000000000000000000000000000000000
6340000000003730028126224923406400060401004002564970604000000
1928000000000000000000000000000000000000000000000000000000000

below is the table of codes that we search for from the file contents as above.

reason_code reason
----------------------------------------------------------------------------------------------------------
0000 NO ERROR FOUND-PROCESSED SUCCESSFULLY
0002 BRANCH CODE NO INVALID
0003 ACCOUNT NO INVALID
0004 INVALID REQUEST
0006 TRANSACTION AMOUNT EXCEEDS LIMIT
0011 BRANCH ACCOUNT COMBO INVALID
0015 BENEFICIARY REFERENCE INVALID
0027 ACCOUNT TYPE INVALID
0028 TRANSACTION ACCOUNT SAME AS CONTRA
0040 INVALID COMBO-PROVILE AND ACCOUNT
0054 ACCOUNT CLOSED
0063 ACCOUNT STOPPED
0083 ACCOUNT NAME MANDATORY


Report •

#9
May 11, 2011 at 13:29:28
Guffy,

I am sorry I wasted your time but now it is time for me to give up. You can't believe I am not only a skilled computer professional but got a deep experience in financial transaction processing. This issue remains confused for me, I understand part of the input but full layout is not enough clear to enable me to work out a solution.

My feeling is the problem is hard to be worked out by batch. I hope my opinion is wrong.

Since this thread is now wasted, please, post again slightly modifying the object so a more experienced guy/gal can help you.

I hope someone can give you the solution you are looking for so I too can learn from his/her code.


Report •


Ask Question