Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

In notepad on every line need to put a number

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

Regards
Sharath
0
Comment
Question by:bsharath
6 Comments
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 2000 total points
ID: 19539915
@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
)
0
 
LVL 1

Expert Comment

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

Expert Comment

by:Farhan Kazi
ID: 19539927
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.
 
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Author Comment

by:bsharath
ID: 19539929
farhankazi
What should i change.

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

Expert Comment

by:thuannguy
ID: 19539935
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.
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19539939
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 here: http://www.experts-exchang…
Issue: One Windows 2008 R2 64bit server on the network unable to connect to a buffalo Device (Linkstation) with firmware version 1.56. There are a total of four servers on the network this being one of them. Troubleshooting Steps: Connect via h…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
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…
Suggested Courses

581 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