Computing.Net > Forums > Programming > make batch file edit text 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.

make batch file edit text file

Reply to Message Icon

Name: mxjf
Date: July 20, 2007 at 18:21:14 Pacific
OS: windows xp
CPU/Ram: intel celeron 2.53ghz, 24
Product: dell poweredge sc420
Comment:

Hi.

I have a text file that has a bunch of stuff that I don't need, but I just need the last line of text.

Is there any way to make a batch file that will open a text file, take that last line of text, paste it into a seperate text file, add a carraige return, and add the text "<ID02><PB>" to the beginning?

Thanks in advance!!!




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: July 21, 2007 at 00:04:43 Pacific
Reply:

:: pluslast.bat
:: put "<ID02><PB>" + last line of myfile into newfile

@echo off
setLocal EnableDelayedExpansion

> newfile echo "<ID02><PB>"

for /f "tokens=* delims= " %%a in (myfile) do (
set last=%%a
)
echo !last! >> newfile



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: ghostdog
Date: July 21, 2007 at 09:45:44 Pacific
Reply:

just a note that if your file is big, looping through the file using line by line till the last would take some time. however if you have no concerns over that, then its ok


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: make batch file edit text file

Create a batch file to edit text file www.computing.net/answers/programming/create-a-batch-file-to-edit-text-file/19035.html

editing text file with batch file www.computing.net/answers/programming/editing-text-file-with-batch-file/15231.html

compiler to make batch files www.computing.net/answers/programming/compiler-to-make-batch-files/9447.html