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
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?
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
Summary: Hi, Could you guys help me make a batch file which will replace an entry in the text file - coming from an environment variable? Basically it'll just replace the username and password: <user userna...
Summary: 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 t...