Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Create 12 monthly folders for specified year

Oct
364
17
This program (a cmd batch file), creates 12 monthly folders for the specified year, without subfolders.

:: Make_12_Month_folders.bat :: :: by Joseph "Rick" Reinckens :: No copyright claimed :: :: Creates a set of subfolders IN THE CURRENT FOLDER in the format: :: 01 - Jan 2014 :: 02 - Feb 2014 :: :: If the GOTO FULL_MONTH line is uncommented it will use the format: :: 01 - January 2014 :: 02 - February 2014 :: :: NOTE: The year is hard-coded and so must be changed annually. @echo off Set Year=2019 :: GOTO FULL_MONTH :: PARTIAL MONTH NAME mkdir "01 - Jan %Year%" mkdir "02 - Feb %Year%" mkdir "03 - Mar %Year%" mkdir "04 - Apr %Year%" mkdir "05 - May %Year%" mkdir "06 - Jun %Year%" mkdir "07 - Jul %Year%" mkdir "08 - Aug %Year%" mkdir "09 - Sep %Year%" mkdir "10 - Oct %Year%" mkdir "11 - Nov %Year%" mkdir "12 - Dec %Year%" GOTO DONE :FULL_MONTH mkdir "01 - January %Year%" mkdir "02 - February %Year%" mkdir "03 - March %Year%" mkdir "04 - April %Year%" mkdir "05 - May %Year%" mkdir "06 - June %Year%" mkdir "07 - July %Year%" mkdir "08 - August %Year%" mkdir "09 - September %Year%" mkdir "10 - October %Year%" mkdir "11 - November %Year%" mkdir "12 - December %Year%" :DONE Dir Pause
 
Last edited:
This might abbreviate it a bit. Associates a "word" number (zero-based) with an integer from 1 to 12. Also uses the built-in %_year variable so of course would have to be done on or after January 1 to have the %_year value be "2019". In this example it only echoes the "md" command rather than executing it.

Code:
setlocal
set mo=x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

do i = 1 to 12
    set m=%i
    if %@len[%m] == 1 set m=0%i
    echo md "%m %@word[%i,%mo] %_year"
enddo
 
Here's a simple 1 liner:
Code:
do m=1 to 12 (MD "%@formatn[02.0,%m] - %@word[%m,. January February March April May June July August September October November December] 2019")

There doesn't appear to be a way to convert a numeric month into the month's name. The _MONTHF, _IMONTH, and _IMONTHF variables do it, but only for the current date. Using a month naming function, it could be done like this:
Code:
function monthf=`%@word[%1,. January February March April May June July August September October November December]`
do m=1 to 12 (echo "%@formatn[02.0,%m] - %@monthf[%m] 2019")
do m=1 to 12 (echo "%@formatn[02.0,%m] - %@left[3,%@monthf[%m]] 2019")
 
I deliberately wrote this one as a cmd-compatible .bat file several years ago. Since it's already done I figured I would post it.

The problem with having it automatically pull the year from the date is that generally this will be run in the last days of the current year to prepare for the new year. The longer one I posted that creates 744 folders--12 months + 2 per day does allow specifying the year as a command-line parameter.
 
Back
Top