E=mc2
asked on
Batch script to search for and replace based on conditions
I would like to know the batch commands for the attached input file that will do the following.
When it sees 01-ABCDA, or 01ABCDB - in position 4 'and' if it sees either 01230c, or 01232 in position 100,
then it will change the last character from whatever 3 digits it sees at the end of those lines, to a ,008.
This is the input script in a .csv file.
5,A,01234,01-ABCDA,Y,1251/ 2,1772345, ,20181003, 20181107,2 0181114,,1 2345678900 00,COMP ACCOUNTS PAYABLE,123 ROAD WAY,,TREEWAY,FL,01234-5678 ,,,,123456 4870004,So mewhere Warehouse,200 Treeview Court NW,,Everywhere,GA,12345-12 34,,,018-4 41-5522,41 245,ABCORP BC,,USD,N, ,,,,,,,,,N ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,00987894 561230,012 30c,152324 ,STEEL,,,, 123.00,US, 0.00,US,0. 00,US,10.5 000,0.0000 ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,101
5,A,01234,01-ABCDB,Y,1251/ 2,1772345, ,20181003, 20181107,2 0181114,,1 2345678900 00,COMP ACCOUNTS PAYABLE,123 ROAR WAY,,TREEWAY,FL,01234-5678 ,,,,123456 4870004,So mewhere Warehouse,200 Treeview Court NW,,Everywhere,GA,12345-12 34,,,018-4 41-5522,41 245,ABCORP BC,,USD,N, ,,,,,,,,,N ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,00987894 561560,012 32,152345, WOOD,,,,78 9.00,US,0. 00,US,0.00 ,US,10.510 0,0.0000,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,102
5,A,01234,67891,Y,1253/2,1 775478,,20 181003,201 81107,2018 1114,,1234 567890000, OTHERCOMP ACCOUNTS PAYABLE,123 ROAD WAY,,FOREST,TX,01234-5678, ,,,1234564 870004,Ano ther Warehouse, 300 Apt View Court NW,Specific Place,TX,12345-5678,,,018- 441-5522,4 1245,DEFOR PBC,,USD,N ,,,,,,,,,, N,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,0098789 4564560,00 456,152322 ,CANVAS,,, ,123.00,US ,0.00,US,0 .00,US,10. 5200,0.000 0,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,103
5,A,01234,55555,Y,1254/2,1 771234,,20 181003,201 81107,2018 1114,,1234 567890000, OTHEROTHER COMP ACCOUNTS PAYABLE,123 ROAD WAY,,JUNGLE,GA,01234-9999, ,,,1234564 870004,BAn other Warehouse, 400 Sea View Court NW,AnotherSpecific Place,GA,12345-9999,,,018- 441-5522,4 1245,GHIOR PBC,,USD,N ,,,,,,,,,, N,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,0098789 4564560,00 456,152322 ,CANVAS,,, ,123.00,US ,0.00,US,0 .00,US,10. 5200,0.000 0,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,104
When it sees 01-ABCDA, or 01ABCDB - in position 4 'and' if it sees either 01230c, or 01232 in position 100,
then it will change the last character from whatever 3 digits it sees at the end of those lines, to a ,008.
This is the input script in a .csv file.
5,A,01234,01-ABCDA,Y,1251/
5,A,01234,01-ABCDB,Y,1251/
5,A,01234,67891,Y,1253/2,1
5,A,01234,55555,Y,1254/2,1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER