Discussion Locked

Current Date + DOS

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am trying to pass the current date into a batch file so that when I run the copy command within it, the file will use the current date as the destination name. Any ideas please ???

6 replies

by opatzg9

I don't know how you'ld do that in a batch file but it is very easy with any basic compiler. And basic programs can be used to accepta command line pass of a file name if you're renaming the file to date/time format. Otherwise there are script programs which use batch commands and add more functionality like Builder which with a short read could do what you're looking for and as an executable would not be modifiable by prying eyes. Hope this helps!

by opatzg9

Try something like this:
filecrlf.txt is a file with a carriage return linefeed
Batch file
date>newname.txt |filecrlf.txt
or
type filecrlf.txt|date>newname.txt
then
copy filename @newname.txt
Which should use it as a list command, just a list of 1
Good luck, still think it can be made a lot cleaner with a compiled program even if it shells out the copy command.

by problemslayer

SET TDATE=%DATE%
XCOPY R:\img\%TDATE%\*.* H:\IMG\%TDATE%\

The "DATE" command returns the current system date. A variable is denoted in the batch file by surrounding the variable name with the %

In my example I have a vaiable called "TDATE" which I set to the system date. I then reference that variable and make its value part of my filenmae path by including it in the path surounded by % signs.

So if my system date was set to WED 12/04/2002 then the xcopy command executed above would actually be:
XCOPY R:\img\WED 12/04/2002 \*.* H:\IMG\WED 12/04/2002 \

This discussion is closed to new replies.