Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Aug 2013
    Posts
    45
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Batch file to create folder

    Hello,

    This batch file code is creating 30 folders on date but the format yyyymmdd (20131101) whereas my required format is DD-MM-YYYY. Will some one help to sort this.

    Code:
    @echo off &setlocal
    for /f "tokens=2,3 delims=-" %%i in ("%date%") do (
      set /a "m = 100%%i %% 100, yy = %%j"
      set "mm=%%i"
    )
    set /a "n=30 + !(((m & 9) + 6) %% 7) + !(m ^ 2) * (!(yy %% 4) - !(yy %% 100) + !(yy %% 400) - 2)"
    setlocal EnableDelayedExpansion
    for /l %%i in (1 1 %n%) do (
      set "dd=0%%i"
    2>nul md %yy%%mm%!dd:~-2!
    )

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,168
    Thanks
    47
    Thanked 978 Times in 908 Posts
    You should always use yyyymmdd format as computers then sort them in date order.

    To get the date information correctly no matter what your date format is, see this post.
    http://windowssecrets.com/forums/sho...and-copy-files

    cheers, Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •