DOS copy command with date stamp

  • Thread starter Thread starter greg w
  • Start date Start date
G

greg w

Hi,

I would like to have somefile.txt be copied into somefile.txt.112404 so
that I can archive the file. I would prefer to do this in DOS and not
VBScript or WSH. Any suggestions?

Thanks in advance, Greg
 
Greg,

add this to the batch file:
FOR /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set My_DayOfWeek=%%i
set My_Month=%%j
set My_Day=%%k
set My_Year=%%l
)

Then you can use the SET variables above to name the files in any order you
want to use such as:
COPY somefile.txt somefile%day%%month%%year%.txt

Hope this helps

Rich
 
here's what i found that works great!

for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set mdate=%%A%%B%%C
copy somefile.txt somefile%mdate%.txt
 
here's what i found that works great!

for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set mdate=%%A%%B%%C
copy somefile.txt somefile%mdate%.txt
 
Back
Top