Computing.Net > Forums > Programming > editing text file with batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

editing text file with batch file

Reply to Message Icon

Name: nexeon
Date: April 12, 2007 at 15:17:36 Pacific
OS: XP
CPU/Ram: Pentium
Product: inspiron
Comment:

I have a text file which has more then 10000 lines in it.
I want to add a < in the begining of each line and > at the end of each line through a batch run.
Can anyone provide me with a batch file that could could automaticallyperform this task


Ram Ethindra



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: April 13, 2007 at 02:39:57 Pacific
Reply:

@Echo Off
For /F "tokens=* delims=" %%J in (myfile_in.txt) Do (
Echo.^<%%J^>>>myfile_out.txt)



0

Response Number 2
Name: nexeon
Date: April 13, 2007 at 07:47:48 Pacific
Reply:

Hello IVO,
Thanks for the reply

I created a batch file with this content:

@Echo Off
For /F "tokens=* delims=" %%J in (C:\Documents and Settings\admin\My Documents\email test.txt) Do (
Echo.^<%%J^>>>C:\Documents and Settings\admin\My Documents\email test1.txt)

It did not do anything

Ram Ethindra


0

Response Number 3
Name: Shr0Om
Date: April 13, 2007 at 13:03:21 Pacific
Reply:

Did you tried quotation around the path?

("C:\Documents and Settings\admin\My Documents\email test.txt")

If that doesnt help, remove "echo off", and then run the batch from the command shell so you can see what errors that occur.


0

Response Number 4
Name: wizard-fred
Date: April 14, 2007 at 04:09:27 Pacific
Reply:

If a batch file doesn't do it, any halfway decent text processor with search and replace should be able to do all but the first and last lines which you can fix manually.


0

Response Number 5
Name: IVO
Date: April 14, 2007 at 09:41:50 Pacific
Reply:

@Echo Off
For /F "tokens=* delims=" %%J in ('Type "C:\Documents and Settings\admin\My Documents\email test.txt"') Do (
Echo.^<%%J^>>>"C:\Documents and Settings\admin\My Documents\email test1.txt")

If a batch file doesn't do it, that almost always is due to the poor knowledge of the basic principles of scripting and NT/DOS statements as "" to mark pathnames with embedded blanks and more advanced rules as those that force here to use a command ('Type...') clause for the For /F statement.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: editing text file with batch file

Editing a txt file with batch files www.computing.net/answers/programming/editing-a-txt-file-with-batch-files/19270.html

Edit text file with FOR command www.computing.net/answers/programming/edit-text-file-with-for-command/16628.html

Batch file to edit text file www.computing.net/answers/programming/batch-file-to-edit-text-file/19329.html