Discussion Locked

copy a file to the current date in NT

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I would like to know if it is possible to copy a file in DOS on a WINNT workstation to the current date. I tried %date% and it did not work. If not in DOS, how about in C ? I have an old copy of a C compiler for Dos. Thanks

3 replies

by joseph moore

Wait a sec. Let me make sure I understand your question.

Are you asking how to copy a file, and have the file name of the copy be the current date? If so, here is how.

Say you want to copy C:\Temp\FILE1.TXT into C:\Backup with a filename of 10-15-2003.txt

This BAT file will do it:

@echo off
c:
cd\
cd temp
for /f "tokens=1-4 delims=: " %%i in ('date /t') do set nowdate=%%j-%%k-%%l
copy FILE1.TXT C:\Backup\%nowdate%.txt
EXIT

This discussion is closed to new replies.