General discussion

Locked

Editing Noteapd through Batch file

By kn_abhilash ·
hi

I have Notepad fle(say test1.txt), having data like below

==========================================
CENTRAL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220

---------- G:\PAGING\COUNTTEMP.TXT: 30

287

---------- G:\PAGING\COUNTTEMP.TXT: 53
718

---------- G:\PAGING\COUNTTEMP.TXT: 0


CITY
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212

---------- G:\PAGING\COUNTTEMP.TXT: 47
221

---------- G:\PAGING\COUNTTEMP.TXT: 43
222

---------- G:\PAGING\COUNTTEMP.TXT: 65

===============================================

actualy i want to edit this as below ( using batch file)

=================================CENTRAL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220---------- 30
287---------- 53
718---------- 0
CITY
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212---------- 47
221---------- 43
222---------- 65

==========================================

i hope u r clear, the 3 digit number should foollow with the number at the end of next line

i want to do all this using a batch file and the edited data should be saved to anotehr file test2.txt

can any one pls give me the codes for this batch file

Thank u very much

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by Joseph Moore In reply to Editing Noteapd through B ...

I don't exactly have it yet, but I am close. Using a single FOR command, you almost get it.

Open a Command Prompt, and CD into the directory with your TEXT1.TXT file. Run this line:

for /f "tokens=1-10 delims=: " %i in (test1.txt) do echo %i %l >> test.txt

Then open TEST.TXT and it will look like this:

CENTRAL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220
---------- 30
287
---------- 53
718
---------- 0
CITY
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212
---------- 47
221
---------- 43
222
---------- 65


So, I am close. This type of thing is usually worked on using Perl. But this is at least a start for you.

Now, if you run this FOR statement in a .BAT file, remember to change the variable names (%i & %l) into %%i and %%l (you need to double up on the percent signs when you use them in .BAT files).

hope this helps

Back to Windows Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums