Welcome!

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

SignUp Now!

Create 366-day month, day, comments subfolder set

Oct
364
17
This program creates a set of 12 monthly folders, day folders in those, "comments" folders in those. It must be run from TCC, not Explorer.

:: Make_Cal-comments_Folders.btm :: :: This requires the free TCCLE or TCC-RT or paid TCC from JPSoft :: :: *** WARNING !!! *** THIS *MUST* BE RUN ONLY FROM A COMMAND PROMPT !!! :: :: If you run it from File Explorer it sticks everything in C:\Windows\System32 :: :: Make_Calendar MM - Mon Year format: 01 - Jan 2015 :: :: by Joseph "Rick" Reinckens :: No copyright claimed :: :: IN THE CURRENT FOLDER Creates 12 month subdirectories and 366 day :: subdirectories AND creates a Comments subfolder for each day :: :: The name of the "Comments" subfolders can be changed by changing :: the Sub_Name variable. :: :: :: FORMAT: :: 01 - Jan 2015 :: 02 - Feb 2015 :: Under the 02 - Feb 2015 folder these folders are created: :: 01 :: 02 :: :: Under THOSE folders a Comments folder is created, i.e. :: F:\MY_FILES\04 - Apr 2016\15\Comments :: :: If you include a parameter, that will be used instead of the year, e.g. :: MAKE_CALENDAR FIRST_YEAR :: Creates subdirs named: :: 01 - Jan FIRST_YEAR :: 02 - Feb FIRST_YEAR :: :: To remove a subdirectory tree from DOS use DELTREE dir_name @echo off :: Defaults to CURRENT year SET YR=%1 IF "%YR%"=="" SET YR=%_year :: Name of the subfolder that will go in each date Set Sub_Name=Comments Echo. :: JANUARY SET MO=01 - Jan Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,31) GOSUB Make_Folders :: FEBRUARY SET MO=02 - Feb Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,29) GOSUB Make_Folders :: MARCH SET MO=03 - Mar Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,31) GOSUB Make_Folders :: APRIL SET MO=04 - Apr Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,30) GOSUB Make_Folders :: MAY SET MO=05 - May Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,31) GOSUB Make_Folders :: JUNE SET MO=06 - Jun Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,30) GOSUB Make_Folders :: JULY SET MO=07 - Jul Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,31) GOSUB Make_Folders :: AUGUST SET MO=08 - Aug Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,31) GOSUB Make_Folders :: SEPTEMBER SET MO=09 - Sep Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,30) GOSUB Make_Folders :: OCTOBER SET MO=10 - Oct Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,31) GOSUB Make_Folders :: NOVEMBER SET MO=11 - Nov Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,30) GOSUB Make_Folders :: DECEMBER SET MO=12 - Dec Echo %MO MKDIR "%MO% %YR%" FOR %%Day_Num in (01,02,03,04,05,06,07,08,09) GOSUB Make_Folders FOR /L %Day_Num in (10,1,31) GOSUB Make_Folders Echo. Echo. Dir pause Quit :Make_Folders MKDIR "%MO %YR\%Day_Num" MKDIR "%MO %YR\%Day_Num\%Sub_Name" RETURN
 
That is way more verbose than it needs to be. I hard coded '2019' and 'Comments' in this example, but you should be able to adapt it as needed.
Code:
setlocal 
function monthf=`%@word[%1,. Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec]`
function mdays=`%@word[%1,. 31 28 31 30 31 30 31 31 30 31 30 31]`
do m=1 to 12
  do d=1 to %@mdays[%m]
    md /s %@formatn[02.0,%m] - %@monthf[%m] 2019\%@formatn[02.0,%d]\Comments
  enddo
enddo
endlocal
 
The long version will work under TCC/LE, which doesn't allow user-defined functions.

It would be easier (example October) to omit
FOR %%Day_Num in (01 ...

And just use:
FOR /L %Day_Num in (1,1,31) GOSUB Make_Folders

And then in Make_Folders
IF %Day_Num LT 10 SET %Day_Num=0%Day_Num MKDIR "%MO %YR\%Day_Num"
 
Do it with a one-liner in TCC versions >25. Replace ECHO with MKDIR /S. You might want to suppress the error message when it tries to make "Jan...\01" a second time in a non-leap year.

Code:
v:\> do i=0 to 365 (echo "%@datefmt[%@instr[0,10,%@agedate[%@eval[%@makeage[%_year-01-01] + %i*864000000000]]],%%b %_year\%%d]")
"Jan 2023\01"
"Jan 2023\02"
[snip]
"Feb 2023\28"
"Mar 2023\01"
[snip]
"Dec 2023\30"
"Dec 2023\31"
"Jan 2023\01"
 
Back
Top
[FOX] Ultimate Translator
Translate