0

I'm using code (from Windows batch: formatted date into variable ).

  1. How to get Mon=08 (2-digits), instead of Aug (3-alpha)?
  2. What is syntax for MKDIR using a variable? With leading \ I get "The filename, directory name, or volume label syntax is incorrect." Without I get "access is denied."

     @echo off
     setlocal 
     for /f "skip=8 tokens=2,3,4,5,6,7,8 delims=: " %%D in ('robocopy /l * \ \  /ns /nc /ndl /nfl /np /njh /XF * /XD *') do (
     set "dow=%%D"
     set "month=%%E"
     set "day=%%F"
     set "HH=%%G"
     set "MM=%%H"
     set "SS=%%I"
     set "year=%%J"
     SET "DESTINATION=%%J%%E%%F%%G%%H%%I-EXTRACTION"
    )
    
     echo Day of the week: %dow%
     echo Day of the month : %day%
     echo Month : %month%
     echo hour : %HH%
     echo minutes : %MM%
     echo seconds : %SS%
     echo year : %year%
     echo DESTINATION : %DESTINATION%
    
     endlocal
    
     MKDIR \%DESTINATION%\
    
Community
  • 1
  • 1
jarhtmd
  • 21
  • 1
  • 5
  • See the answers to this question: http://stackoverflow.com/questions/3472631/how-do-i-get-the-day-month-and-year-from-a-windows-cmd-exe-script – Benvorth Aug 12 '15 at 19:46

1 Answers1

0
  1. This would be an easy way to do it.

set "folder_name=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%-EXTRACTION" md "%folder_name%"

  1. In the above program you just need to put MKDIR "%DESTINATION%" before endlocal and the %DESTINATION% should be inside double quote.

MKDIR "%DESTINATION%" endlocal