ProductRecommendationSystemv2 / folder_management.py
sanjeev21's picture
Create folder_management.py
1ba84a7
Raw
History Blame Contribute Delete
911 Bytes
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))