Creates a series of folders from a given starting date I made this python script to create dated folders within a directory. This is my first practical automation project and I don't want to cement any bad habits so I was wondering if there is anything I can improve in the code I have written here. Any feedback will be appreciated!
The main challenge I had was to account for months with different day ranges, and then to reset the counts properly for all the variables. I feel like this is more complicated than it probably needs to be but I don't know if there are some python libraries I am unaware of that could help simplify it more.
I thought about having a predefined end date as well but that would require the user to open up a calendar and find 2 dates. I figured by just asking for a start date and how many folders they want, I could make things simpler for the end user but I'm not even sure that that is actually the case.
I also don't know if I've used classes correctly here. At first I had everything thrown into the while statement. I also considered using a for loop instead of while but went with while instead. Again, this is my first real project so any help with other decisions I could have made will be appreciated!
import os
import pathlib

directory = &quot;/Users/myName/Box Sync/SAFAC/Budget Requests/2020-2021/Weekly/&quot;

# directory = input(&quot;Enter the path where you would like to create files: &quot;)
date = input(&quot;Enter the starting date in mm-dd-yyyy format: &quot;)
period = int(input(&quot;Enter the period between each date folder: &quot;))
instances = int(input(&quot;How many folders do you want? &quot;))

Folders = []

arguments = date.split(&quot;-&quot;)
dayArgument = arguments[1]
monthArgument = arguments[0]
yearArgument = arguments[2]
init = instances - instances
elapse = period - period
seperator = &quot;-&quot;

month = int(monthArgument)
day = int(dayArgument) + int(elapse)

def make_directories(input_list):
    for folderName in input_list:
        dirpath = os.path.join(directory, folderName[0:],'Documentation')
        try:
            os.makedirs(dirpath)
        except FileExistsError:
            print('Directory {} already exists'.format(dirpath))
        else:
            print('Directory {} created'.format(dirpath))

def add_folder_to_list(month,day,year,extra):
    full_name_constructor = (month,day,year,extra)
    # full_name_constructor = (str(month),str('0'+str(day)),yearArgument,&quot;Budgets&quot;)
    fullName = seperator.join(full_name_constructor)
    Folders.append(fullName)

def format_and_append_folder_name():
    if day &lt; 10 and month &gt;= 10:
        add_folder_to_list(str(month),str('0'+str(day)),yearArgument,&quot;Budgets&quot;)
    elif day &gt;= 10 and month &lt; 10:
        add_folder_to_list(str('0'+str(month)),str(day),yearArgument,&quot;Budgets&quot;)
    elif day &lt; 10 and month &lt; 10:
        add_folder_to_list(str('0'+str(month)),str('0'+str(day)),yearArgument,&quot;Budgets&quot;)
    else:
        add_folder_to_list(str(month),str(day),yearArgument,&quot;Budgets&quot;)

def check_month():
    global maxDays 
    if (month % 2 ) == 0 and month != 2 : # if even but not February
        maxDays = 30
    elif month == 2 :
        maxDays = 28 #if February
    else :
        maxDays = 31 # if odd


while init &lt; instances :
    check_month()
    format_and_append_folder_name()
    make_directories(Folders)
    # print(Folders[init])            # for debugging

    init += 1
    elapse += period
    day = int(dayArgument) + int(elapse)

    if day &gt; maxDays :
            month += 1
            day -= maxDays                  # reset days
            dayArgument = day               # recalibrate the new zero point for the day to be the date in the new month
            elapse = 0                      # recalibrate elapse point to 0 so it can reiterate the period again
OK let's look at your code.
Unused Imports
pathlib was imported but I don't see any use of it in the codebase, I understand that this might be as a result of testing out approaches to a problem. pylint can help mitigate this by catching unused modules. It also catches some PEP guidelines which your code breaks.
Avoid Globals
You have lots of global variables. A common approach whenever you want to use a global is asking yourself some questions; &quot;How do I express myself with code whilst avoiding this global variable&quot;. When in doubt,  prefer objects that holds state to global variables.
Code Review
On first glance,  I can see you are manually parsing dates. This doesn't look good, you introduce bugs when reinventing the wheel. Right now,  your code contains a bug,  it accepts invalid dates,  I can easily create a date like this
date = &quot;12-03-202022&quot;
The above code generates no error, this can be disastrous.
A common alternative is using python  datetime module. This simplify everything, we can move the dates by periods easily,  creating directories becomes quite easy.
NOTE: datetime  module checks for invalid dates.
A simple way of creating a date from a string is given as
from datetime  import datetime
date = datetime.strptime(start_date, &quot;%d/%m/%y&quot;)

This simple line of code simplifies everything,  the full code can then be written as
&quot;&quot;&quot;Directory creating program&quot;&quot;&quot;

import os
from datetime import datetime, timedelta

def next_date(date, period):
    &quot;&quot;&quot;Increase the date by timedelta
        date: datetime object
        period: timedelta to increase our date by
    &quot;&quot;&quot;
    new_date = date + timedelta(days=period)
    return '/'.join((str(new_date.day), str(new_date.month), str(new_date.year))), new_date

def make_directories(home_dir, start_date, instances, period):
    &quot;&quot;&quot;Create sub directories in the home_dir

        home_dir: base directory
        start_date: date to append to directories created
        instances: number of directories to create
        period: difference between two dates
    &quot;&quot;&quot;
    date = datetime.strptime(start_date, &quot;%d/%m/%y&quot;)

    for i in range(instances):
        start_date = start_date.replace('/', '-')
        dirpath = os.path.join(directory, start_date,'Documentation')
        try:
            os.makedirs(dirpath)
        except FileExistsError:
            print('Directory {} already exists'.format(dirpath))
        else:
            print('Directory {} created'.format(dirpath))

        start_date, date = next_date(date, period)

if __name__ == &quot;__main__&quot;:
    directory = &quot;/Users/myName/Box Sync/SAFAC/Budget Requests/2020-2021/Weekly/&quot;
    make_directories(directory, '3/1/20', 10, 5)