File size: 911 Bytes
16624b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os


# Folder Management Functions
def create_folder(folder_name):
    '''create specified folder in the root directory, if it doesn't exist already! Requires OS Module.'''
    try:
        os.mkdir(folder_name)
        print('Created the folder: "{}"'.format(folder_name))
    except FileExistsError:
        print('Folder Already Exists!!')


def remove_files_folder(folder_name):
    '''Removes files from specified folder and deletes the folder from the root directory. Requires OS Module.'''
    try:
        for file in os.listdir(folder_name):
            os.remove(os.path.join(folder_name, file))
        print('Cleared all the content from the "{}" folder.'.format(folder_name))
        os.rmdir(folder_name)  # Removing the Empty Folder
        print('Removed the "{}" folder.'.format(folder_name))

    except FileNotFoundError:
        print("Folder '{}' doesn't exist.".format(folder_name))