Batch output question

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Jayrome
Posts: 7
Joined: 13 Jun 2011 21:44
Location: Australia

Batch output question

#1 Post by Jayrome » 30 Jun 2011 02:39

I currently have a batch file which I run to output URLS into a text file seperated by the date as you can see below. Everytime I run the batch file to add new info into the output file it adds it to the bottom of the page. Which command will add it to the top of the page so i'm not having to scroll all the way to the bottom for the latest information?

Thanks :)

———————————
Thu 30/06/2011
———————————
URL
URL
URL
URL
———————————
Thu 30/06/2011
———————————
URL1
URL1
URL1
———————————
Thu 30/06/2011
———————————

New URL
New URL

Acy Forsythe
Posts: 126
Joined: 10 Jun 2011 10:30

Re: Batch output question

#2 Post by Acy Forsythe » 30 Jun 2011 07:41

There isn't a command, but something like this would work...

Code: Select all

@echo off

... Run your commands as normal from your script >> NewOutputFile.txt

For /F "tokens=* delims=" %%a IN (OldOutputFile.txt) DO echo %%a >> NewOutputFile.txt

DEL /Q OldOutputFile.txt
REN NewOutputFile.txt OldOutputFile.Txt


All your new stuff goes to the top of NewOutput file then all the stuff from OldOutputFile goes in after it.

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: Batch output question

#3 Post by nitt » 30 Jun 2011 11:19

Acy Forsythe wrote:There isn't a command, but something like this would work...

Code: Select all

@echo off

... Run your commands as normal from your script >> NewOutputFile.txt

For /F "tokens=* delims=" %%a IN (OldOutputFile.txt) DO echo %%a >> NewOutputFile.txt

DEL /Q OldOutputFile.txt
REN NewOutputFile.txt OldOutputFile.Txt


All your new stuff goes to the top of NewOutput file then all the stuff from OldOutputFile goes in after it.


If all we are doing is adding something to the top, all we have to do is

Code: Select all

@echo off
echo newinformation > tmp.txt
type original.txt >> tmp.txt
echo y|move "tmp.txt", "original.txt"

Post Reply