In notepad on every line need to put a number

Posted on 2007-07-21
Last Modified: 2010-03-05
I have 100's of lines in a notepad file.Is there a way to put a number in front of every line.

Question by:bsharath
    LVL 26

    Accepted Solution

    @Echo Off
    SetLocal EnableDelayedExpansion
    SET FileName=C:\File.txt
    set /a counter=1
    FOR /F "delims=*" %%L IN ('Type %FileName%') Do (
          Echo !Counter! %%L >>C:\New_File.txt
          set /a counter+=1
    LVL 1

    Expert Comment

    If you want to go to a specific line-number in notepad, press Ctrl+G enter the line number and ok.
    LVL 26

    Expert Comment

    Above script will generate 'New_File.txt' on C: drive root with line number on start of each line.
    You need to set 'FileName' variable inside the script to actual file name.
    LVL 11

    Author Comment

    What should i change.

    Will this put a line no to each line in the file.
    LVL 6

    Expert Comment

    Hihi, I usually use this trick: copy the content to the second column of an excel sheet, and then insert whatever we want to the first column.
    LVL 26

    Expert Comment

    You need to set 'FileName' variable inside the script to actual file name.

    Like in original file if you have a text like:
    I have
    100's of
    lines in a
    notepad file.
    Is there a way
    to put a number
    in front of every line

    then it will generate new_file with following output.
    1 I have  
    2 100's of  
    3 lines in a  
    4 notepad file.
    5 Is there a way  
    6 to put a number  
    7 in front of every line

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    On a regular basis I get questions about slow RDP performance, RDP connection problems, strange errors and even BSOD, remote computers freezing or restarting after initiation of a remote session. In a lot of this cases the quick solutions made b…
    Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found listed in my profile here: http:…
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now