FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET DATE=%yyyy%%mm%%dd%
Of course you can set the DATE environment variable we created in any format you need. Here's a practical application to copy SQL's dated backup files to a DRP location:
robocopy \\Server1\SAN_DBData d:\nightlyBACKUPS *%DATE%*.BAK /s /r:0 /w:0 /nfl /ndl /np /log+:CopyNightlyDBBackups.LOG
No comments:
Post a Comment