I want to insert no’s into a txt (Text) file.

Asked By 7060 points N/A Posted on -
qa-featured

I want to insert no's into a txt file. I periodically get a lot of text files from a software which needs numbering. I want a script that can insert no's in from of each word in every line. Can anyone help me with a script to do it. Preferably a batch script.

SHARE
Best Answer by Sharath Reddy
Best Answer
Best Answer
Answered By 557975 points N/A #79207

I want to insert no’s into a txt (Text) file.

qa-featured

Here is a solution for you. Script that can insert no’s into a Notepad file Create a bat file and name it as you wish or as shown below:

Create a bat file and name it as you wish

Data marked in red is the place you need to change. Data marked in red is the place you need to change.

Insert this code in the bat file you created. Code starts here……………………………. @echo off setlocal set counter=1 for /F "tokens=*" %%G in (c:Oldfile.txt) do call :_process "%%G" goto :_end :_process echo %counter%. %~1 >> c:Newfile.txt set /A counter+=1 goto :eof :_end endlocal Code end’s Here……………………………….. Then create a txt file with the name “oldfile.txt” with the desired content in the file for which you want to place no’s.

create a txt file with the name “oldfile.txt”

And then double click on the “bat” file. It will create a file named “Newfile.txt”

create a file named “Newfile.txt”

Inside which now the data will look like this.

Inside which now the data will look like this

Hope this helps.

Answered By 40 points N/A #79208

I want to insert no’s into a txt (Text) file.

qa-featured

HIP HIP HURRAY !

Thank you so much MR. Sharath Reddy. My boss always send me text files like this to number them. Usually each file have 10,000+ name and other details in it and asks me to complete it in less than 1 hour. Really its a difficult task to number each line. Now you guys really made it very easy. Thanks for the script MR. Sharath.

I really appreciate you in helping me from this crisis which I was facing more than 1 month.

Thanks to techyv.com

WE ALL CAN MAKE DIFFERENCE! YEAH NOW ITS VERY TRUE!

Login/Register to Answer

Related Questions