Windows macro for appending to files

Status
Not open for further replies.

DEADFA11

Solid State Member
Messages
10
Hello,

For the task I'm currently working on, I often find myself typing the following line at the command prompt:

> echo "some_string" >> filename.txt

with the desired result being "some_string" appended to the end of the file. The thing is, I am always appending to the same file, so it would be convenient for me to have a doskey macro to cut down on the typing. Here's what I tried:

> doskey ec=echo $1 >> filename.txt

I would have thought this would allow me to type:

> ec "some_string"

and have the string automagically appended to the file specified in the macro. However, all it does is echo "some_string" to standard output, without appending to the file, like this:

> ec "some_string"
"some_string"

Is there a way to properly construct this macro, or will I have to avoid the problem by writing a script and setting my macro to call that script?
 
you can write a batch file that accepts one argument as follows

Code:
echo %1 >> filename.txt

if you name this file runme.bat, then then the command you would want to repeat is

runme "some string"
runme "some string #2"
runme "some string #3"
 
Status
Not open for further replies.
Back
Top Bottom