I'm trying to write a script that copies a folder every week night. I would like it to create a folder each night in the destination directory.
So I'm trying to make a script that copies "C:\logs" to "I:\logs\today's date"
So the destination folder should look like this
"I:\logs\Monday_1272014" then the next night it should look like this "I:\logs\Tuesday_1282014"
and so on for each weekday. I'm not sure if I'm making sense, but any help would be appreciated.
So far I have this for the Robocopy script: robocopy "E:\Batch Files" "I:\Backups\Monday" /MIR
But that would just create a folder named Monday. Any help would be greatly appreciated. Also, it does not have to be robocopy. I just use that because it's the only one I know. I wouldn't mind learning how to do it as a batch file or VB Script.
Thanks!
The first four lines of this code will give you reliable YY DD MM YYYY HH Min Sec variables in XP Pro and higher.
@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "datestamp=%YYYY%%MM%%DD%"
Alter the order of %yyyy%
and %mm%
and %dd%
to suit you and then you can add the variable to Robocopy:
robocopy "E:\Batch Files" "I:\Backups\%datestamp%" /MIR