diff --git a/services_scripts/basic_functions.py b/services_scripts/basic_functions.py index a991301..9fb9536 100644 --- a/services_scripts/basic_functions.py +++ b/services_scripts/basic_functions.py @@ -1,4 +1,4 @@ -import os +import os, glob def create_folders(directory, num_folders): @@ -18,4 +18,15 @@ def create_folders(directory, 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 + print(f"Created folder: {folder_path}") + + +# In a folder (including several sub folders) this function extract +# .shp files from each subfolder +def find_shp_files(root_folder): + shp_files = [] + for foldername, _, _ in sorted(os.walk(root_folder)): # Sort folders alphabetically + 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