import os import glob import time def find_shp_files(root_folder): shp_files = [] # Sort folders alphabetically for foldername, _, _ in sorted(os.walk(root_folder)): for filename in sorted(glob.glob(os.path.join(foldername, '*.shp'))): new_file_name = filename.replace('\\', r'/') 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}") def create_output_folders(paths_dict, output_dir): for path in paths_dict.keys(): new_folder = path.lower().replace(' ', '_') output_path = output_dir + '/' + new_folder os.mkdir(output_path) if path[-1] != 's': paths_dict[path] = output_path + f'/{new_folder}.shp' else: paths_dict[path] = output_path