DOS BATCH FILE TO NAME FILES BY DATE

  • Thread starter Thread starter Adrian Moseley
  • Start date Start date
A

Adrian Moseley

Hello guys and gals,

I have an xxcopy script that copys files here and there just fine. My
question regards the log file that is created that shows what was copied. I
would like for the file to be named 'name-mmddyyyy.txt' but I dont know how
to pull the date into a variable..

my first attempt at this was done by breaking the script into two files to
pull the date, but it only gives the day of the week.

#### FILE
@echo off
D:\RFMCOPY\RFMCOPY.CMD %DATE%

#### FILE 2
xxcopy J:\output1\040?\*\????_tc??????.ps Q:\output1\ /I /BB
/oND:\RFMCOPY\%1-RFMCopy.txt


The two scripts above will give me something like MON-RFMCopy.txt, which is
ok.. but I need a lil more information in the file name. Does anyone know if
there is a way for me to add the date in MMDDYYYY format to my file name?
Thanks.
 
This should give you some hints.

@echo off
echo. |date>date.txt
FOR /F "eol=E tokens=4,5,6,7,8* delims=/, " %%i in (date.txt) do Set Z=%%k-%%l-%%m
move "%~1" "%~1%Z%"
del date.txt

Make a batch file with these lines in it, drop a folder on it, folder renamed.

New Folder becomes New Folder01-12-2003
 
You da man!!


This should give you some hints.

@echo off
echo. |date>date.txt
FOR /F "eol=E tokens=4,5,6,7,8* delims=/, " %%i in (date.txt) do Set
Z=%%k-%%l-%%m
move "%~1" "%~1%Z%"
del date.txt

Make a batch file with these lines in it, drop a folder on it, folder
renamed.

New Folder becomes New Folder01-12-2003
 
Back
Top