Page 1 of 1

Cut text after nth comma using batch script

Posted: 08 Apr 2019 09:40
by masteryoda851
I have file like below

ai,one,qew
bet,two,erfv
cars,three,eie

and I need output like below

ai,one
bet,two
cars,three

I need windows script to do this. Here the should be deleted based on 2nd comma

Re: Cut text after nth comma using batch script

Posted: 08 Apr 2019 10:35
by Aacini
Another way to say the same thing is that you want the first and second tokens delimited by comma, isn't it?

Code: Select all

for /F "tokens=1,2 delims=," %%a in ("theFile.txt") do echo %%a,%%b
Antonio