diff --git a/ListAllShapefiles_inDirectoryAndSubDirectories_5th_option.py b/ListAllShapefiles_inDirectoryAndSubDirectories_5th_option.py new file mode 100644 index 0000000..c70a5a4 --- /dev/null +++ b/ListAllShapefiles_inDirectoryAndSubDirectories_5th_option.py @@ -0,0 +1,34 @@ +#------------------------------------------------------------------------------- +# Name: module1 +# Purpose: +# +# Author: seagles +# +# Created: 11-01-2024 +# Copyright: (c) seagles 2024 +# Licence: +#------------------------------------------------------------------------------- + +import os + +path = os.getcwd() + +print path + " = PATH" + +if __name__ == "__main__": + List_Files = [] + for (root,dirs,files) in os.walk(path, topdown=True): + print (root) + #print (dirs) + #print (files) + files = os.listdir(root) + files = [f for f in files if f.lower().endswith('.shp')] + if len(files)==0: + print("there are no files ending with .shp in your folder") + else: + print('There are {} shapefiles in your folder'.format(len(files))) + for f in files: + print root + "\\" + f + List_Files.append(root + "\\" + f) + print ('--------------------------------') +print List_Files \ No newline at end of file