Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
get TIME & DATE into var
Name: Mechanix2Go Date: March 4, 2005 at 11:41:45 Pacific OS: w2k CPU/Ram: PIII 933 / 256
Comment:
Here's a challenge for you.
Get TIME & DATE into env vars using only DOS internal commands.
are you in the mood of kidding? Well, I set the date only and, as I am Italian and I do not have an English edition of DOS on hand, let us assume the output of the Date command be
Current date is Mon yyyy-dd-mm Enter the new date:
So assumed your code is
@Echo Off Echo. | Date > X.bat Echo @Set MyDate= %3 %4> Current.bat X
and you are done. Anyone to complete the exercise?
0
Response Number 2
Name: jboy Date: March 4, 2005 at 13:27:49 Pacific
Name: Dan Penny Date: March 4, 2005 at 17:59:49 Pacific
Reply:
Son of a gun. A fast glance at the address told me it was different so I posted the one I had. Sorry, I ~should~ have gone to the site (your post) to check it. ;>{
0
Response Number 6
Name: dtech10 Date: March 5, 2005 at 15:29:58 Pacific
Reply:
This causes three Commands not found errors. buts worked in Dos5. the "dir abc123.bat > abc1234.bat" could be changed to "dir abc123.bat | find "ABC123" > abc1234.bat" to stop these errors.
@echo off rem Sets XDATE & XTime environment varables echo @echo off > abc123.bat echo set XDATE=%%3 >> abc123.bat echo set XTIME=%%4 >> abc123.bat dir abc123.bat > abc1234.bat call abc1234.bat del abc123.bat > nul del abc1234.bat > nul
0
Response Number 7
Name: jboy Date: March 5, 2005 at 16:18:58 Pacific
Reply:
"This causes three Commands not found errors"
??
0
Response Number 8
Name: dtech10 Date: March 5, 2005 at 16:34:55 Pacific
Reply:
Hi JBoy I said that it did ,but these could be stopped by the Find commannd above.
0
Response Number 9
Name: jboy Date: March 5, 2005 at 17:08:02 Pacific
Reply:
That exact error is unfamiliar to me - but the idea behind decent batching is not to generate error messages. At best it's... inelegant.
0
Response Number 10
Name: Mechanix2Go Date: March 6, 2005 at 23:30:09 Pacific
Reply:
Hi gang,
I knew many of you could do this easily.
Especially IVO.
;)
dtech10, thanks for that. I'm looking it over know.
Summary: Hi Multiplexed, Plenty of ways to set vars in jboy's link. The general setting of time & date vars was answered about 15 msgs ago in this forum. As to scheduling. Correct; there is no AT in DOS. Since...
Summary: People, Basically firstly want to say cheers to Leonardo (aka Secret_doom) for helping me out with this one. So much help and solved a big headache for me! I owe him a beer! I used one of his batch sc...
Summary: Hi, I would like to rename a file (which is copied from another location) to have the current date reflected in the filename. Here is my batch file, but not working in the line with REN command... ---...