From 7bbd538d2fafb64db7753a0a1483c0d5106a40e4 Mon Sep 17 00:00:00 2001 From: Alireza Adli Date: Tue, 26 Mar 2024 19:22:32 -0400 Subject: [PATCH] Add create folders function --- basic_functions.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/basic_functions.py b/basic_functions.py index a6c040a..b99c5bc 100644 --- a/basic_functions.py +++ b/basic_functions.py @@ -12,3 +12,22 @@ def find_shp_files(root_folder): shp_files.append(new_file_name) return shp_files + +def create_folders(directory, num_folders): + """ + Create a specified number of folders in the given directory. + + Args: + - directory (str): The directory where folders will be created. + - num_folders (int): The number of folders to create. + """ + # Check if the directory exists, if not, create it + if not os.path.exists(directory): + os.makedirs(directory) + + # Create folders + for i in range(num_folders): + folder_name = f"layer_{i}" + folder_path = os.path.join(directory, folder_name) + os.makedirs(folder_path) + print(f"Created folder: {folder_path}") \ No newline at end of file