PDA

View Full Version : Environment Variable


Sylvor
05-15-2002, 09:23 AM
Hi guys,

I am trying to set up a dodgy old batch file to backup files on a PC to a network location.

I want the batch file to run at login and to create a folder using todays date (date must change each day!), then copy all files from the PC to the network http://www.PCGuide.com/ubb/smile.gif

To do this I wanted to use environment variables, to control the date... but I'm not sure how to setup a "DATE" variable.

Any help would be... embarrassing http://www.PCGuide.com/ubb/smile.gif


------------------
Sly :)

"Helping everyday people with everyday problems, everyday!"

"The ability to quote is a serviceable substitute for wit"

Ghost_Hacker
05-15-2002, 04:22 PM
I use date and now with VBscript and `date +'%b %e'` with Perl. In DOS you can try %date%.

Hope this helps http://www.PCGuide.com/ubb/smile.gif

david eaton
05-17-2002, 05:51 PM
Hi, Slyvor.
This one made me think, and start rooting through some old manuals! I found this batch file for DOS6, so I expect it will be OK

1 echo. |date|find"current">$$$$date
2 echo@echo off >$$$1date.bat
3 echo set todayis=%%5>> $$$1date.bat
4 echo@echo off > $$$2date.bat
5 prefix $$$$date $$$2date.bat $$$1date
6 call $$$2date
7 del $$$$date
8 del $$$1date.bat
9 del $$$2date.bat
10 :quit

Might do what you want as the current date ends up stored as an environment variable "todayis"

hope that helps

David


------------------
If man could be crossed with the cat, it would improve the man, but disimprove the cat.

Mark Twain

[This message has been edited by david eaton (edited 05-17-2002).]