# Modify dos variable and append to file



## Toddles18 (Jul 18, 2001)

I'm writing a script to append email address to a list. I have userid setup as a enviornmental variable %_USERID% What I need is for the batch file to take that variable, add a "<" before it and "@e-hps.net>" after it and append it to list.txt

So say the value of %_USERID is Todd, it would append the line <[email protected]> to file list.txt

I hope someone can help me out with this.


----------



## Squashman (Apr 4, 2003)

not sure if you can echo either one of these characters < >

I know how to do it in linux but I cant seem to do it in dos.

The only way I have been able to echo the special characters is to put them in quotes which will also echo the quotes.

Doing this:
set username=josh
echo "<%username%@mail.com>" >> emaillist.txt

gives you this;
"<[email protected]>"


----------



## Squashman (Apr 4, 2003)

I knew there had to be a character like the backslash in Linux that does the same thing for dos. It is the carrot. The carrot before a character, tells the command interpreter to see it literally as a conventional character.

@echo off
set username=josh
echo ^<%username%@mail.com^> >> emaillist.txt

I am sure you can modify this to your needs


----------



## Toddles18 (Jul 18, 2001)

Thank you much, that should work just fine!


----------

