:: Use WMIC to retrieve date and time
FOR /F "skip=1 tokens=1-6" %%G IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
IF "%%~L"=="" goto s_done
Set _yyyy=%%L
Set _mm=00%%J
Set _dd=00%%G
Set _hour=00%%H
Set _minute=00%%I
Set _seconds=00%%K
)
:s_done
:: Pad digits with leading zeros
Set _mm=%_mm:~-2%
Set _dd=%_dd:~-2%
Set _hour=%_hour:~-2%
Set _minute=%_minute:~-2%
Set _seconds=%_seconds:~-2%
:: Display the date/time in ISO 8601 format:
Set _isodate=%_yyyy%-%_mm%-%_dd% %_hour%:%_minute%:%_seconds%
REM Echo %_isodate%
set DateTimeNow=%_yyyy%%_mm%%_dd%%_hour%%_minute%%_seconds%
REM echo DateTimeNow=%DateTimeNow%
GOTO:EOF
@echo off
setlocal enabledelayedexpansion
call DateTime-YYYYMMDDHHMMSS_wmic.bat
set destdir=\\ncxxx1\xxx_development$\Publishing\XXX\_XXX Spreadsheet Backups\%_yyyy%-%_mm%-%_dd%
ECHO if not exist "%destdir%" md "%destdir%"
ECHO Copy "\\ncxxx3.corp.xxxx.ca\productiongraphics$\XXX Spreadsheets\*.xls*" "%destdir%"
Open in new window
This will create the folder CAP Spreadsheet backups, (even if it doesn't exists).
Then will get all the excel files on the source path.
and then will create a folder with the today's date under the (Cap spreadsheet backups\yyyy-MM-dd\)
and finally will copy all the files from source to this latest target. if there is a need to correct something let me know since the "date" and the CAP weren't too clear for me.