Hi and thanks in advance. I'm new to batch scripting and would like to perform the following action daily in my server. I need to make sure the directory path
year/month/day exists in a given subfolder, if not create it.
I researched online but I could only find scripts that make
yyyymmdd type directory names and create only one level in the directory tree structure.
I found the following example in this blog.
:: Auto directory date batch (MMDDYYYY format) :: First parses month, day, and year into mm , dd, yyyy formats and then combines to be DDMMYYYY :: Setups %date% variable :: @author Deepu Mohan Puthrote www.deepumohan.com @echo off 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=%dd%%mm%%yyyy% echo New folder name %date% MKDIR %date%