troubleshooting Question

Script searches for a code then looks in a position and writes a new number in the content

Avatar of E=mc2
E=mc2 asked on
Windows BatchWindows OSScripting Languages
3 Comments1 Solution194 ViewsLast Modified:
I am working with a .csv file and I need to change some of the contents.  - let's name it newfile.csv
Below is an example of the content.  These are only 2 lines, however there could be multiple lines in one .csv file.
In this sample, each line starts with 9,J.. and in this case ends with 002.. however each line can be different..

I would like a simple .bat script which will look at position 4 first - if it sees 65-ABCDEF then it looks at position 101.
If position 101 is blank, then it looks in position 100, and looks at tast 6 digits of position 100,  takes those six numbers - removes the last didit, and
write the 5 digits in position 101 - without touching the rest of the data and saving it to a new file called newfile1.csv

So in the examples below, since in position 4 it sees 65-ABCDEF, it then looks in position 101 and sees that it's blank.. therefore it looks at position 100.
There in the first line it sees the number 12345678123452 - therefore it will look at the last 6 digits.. being 123452, remove the last digit, and then it will write those digits
in position 101.. so side by side positions 100 and 101 would look like this before it moves on to the next line..   12345678123452,12345,

Thanks in advance for any assistance you can provide.

9,J,01234,65-ABCDEF,N,1234/2,12345612314,,20190220,20190319,20190319,,1234567890000,Company Inc.,987 Street,,Somewhere,AB,ABC DEF,AM,,,1234567891234,ABC 1234,1 Boulevard,,Here,AB,ABC FGH,AM,,,9876543219876,CORP,0001-,AMA,Y,,,,,,,,,,N,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,20190313,,,,,,,12345678123452,,123456,Desc,,,,10.00,AM,0.00,BC,0.00,AK,10.0100,0.0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,001
9,J,01234,65-ABCDEF,N,1234/2,12345612314,,20190220,20190319,20190319,,1234567890000,Company Inc.,987 Street,,Somewhere,AB,ABC DEF,AM,,,1234567891234,ABC 1234,1 Inkster Boulevard,,Here,AB,ABC FGH,AM,,,9876543219876,ORP,0001-,AMA,Y,,,,,,,,,,N,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,20190313,,,,,,,1234567867892,,789123,Desc,,,,11.00,AM,0.00,BC,0.00,AK,11.0200,0.0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,002
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros