Text to batch automatically

September 10, 2009 at 10:44:46
Specs: Windows XP
I'd like to make a batch file which would simply add one or more lines of text to the the beginning a file and I'd like to be able to automatically update the file through running the batch file.

For example, lets say the text file contains:

Martha Stewart
220 Mandarine Honey Road
Prince Edwards Island, Fantasy Land

and I'd like to add the following line:

Status: active

final output should be:

Status: active
Martha Stewart
220 Mandarine Honey Road
Prince Island, Fantasy Land

But I dont want to have to go into the file directly but rather have a batch file update this line into it automatically.

Thanks for any help

See More: Text to batch automatically

Report •

September 10, 2009 at 11:17:18
Adding before means rewriting the file. Append old file to your add line file to make new file. erase old file. rename new file to old file.

Report •

September 10, 2009 at 11:19:44
how would i do that?

Report •

September 10, 2009 at 11:58:31
You could make your batch file simply combine files.

Lets say the original file was named "Address.txt" and you wanted to add "Status".txt at the top.

Your batch file would be like this:

copy /b Status.txt+Address.txt Combine.txt

The file Staus.txt would need one line feed after "Status:active" in order for it to not to continue as the first line of the Address.txt file. The combination will appear as a new file "Combine.txt".

This might not be quite what you want but it might be useful food for thought and it does work.

some other bloke...

Report •

Related Solutions

September 10, 2009 at 12:04:26
The original text file is a output of a stored procedure. this text files is saved as filename_dateandtime.txt it is to this file i want to add 2 lines on the top.

If i rename it and create a new one, then i have to do it for all the time i run the stored procedure as the file name differes everytime i run the stored proc.

Is there a more generic method for this.
or should any kind of code be added tot he stored proc.

Report •

September 11, 2009 at 10:45:04
Thank you Derek.

Report •

September 11, 2009 at 16:30:35
Sorry I can't be more help. This post seems to have gone pretty quiet but maybe the right person will spot it eventually, so keep an eye on it just in case.

some other bloke...

Report •

Ask Question