Skip to content

Instantly share code, notes, and snippets.

@maptastik
Last active December 6, 2018 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maptastik/aa890f0b1c024e0689a2b7bc095213a1 to your computer and use it in GitHub Desktop.
Save maptastik/aa890f0b1c024e0689a2b7bc095213a1 to your computer and use it in GitHub Desktop.
Function that takes a directory as a parameter and returns a list of shapefiles. Although this doesn't explicitly involve arcpy, this function could be used for automating an action on all shapefiles in a directory using arcpy. That said, it could be
import os
def shps_in_dir(search_directory, full_path = True):
shp_list = []
for file in os.listdir(search_directory):
if file.endswith('.shp'):
shp_list.append(file)
if len(shp_list) > 0 and full_path:
shp_list = list(map(lambda x: os.path.join(search_directory,x), shp_list))
return shp_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment