Solved Create Folders on Date

November 23, 2013 at 23:43:53
Specs: Windows 7
Hi,

With below codes i am trying to create 30 folders named on date (ddmmyyyy).

i.e. 01112013 to 30112013 but i am unable to do so.

@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!
)


See More: Create Folders on Date

Report •


#1
November 24, 2013 at 14:54:29
In order to troubleshoot, one would need to know wgat %date% looks like.

=====================
M2 Golden-Triangle


Report •

#2
November 24, 2013 at 19:54:33
Hi,

Command prompt>date

The current date is 25-11-2013
(dd-mm-yy)


Report •

#3
November 25, 2013 at 06:13:04
✔ Best Answer
Looks like you're using Win7, so PowerShell's an option.
1..31 | ForEach-Object { (Get-Date "$_-11-2013").ToString("ddMMyyyy") }

How To Ask Questions The Smart Way

message edited by Razor2.3


Report •

Related Solutions


Ask Question