I am trying to list datasets within a directory. I have played with ListDatasets and ListFeatureClasses. These work successfully with geodatabase and CAD layers. How do I construct a Python script that lists shapefiles?
import arcpy # Set workspace environment to a folder arcpy.env.workspace = "c:/temp" # A list of shapefiles arcpy.ListFeatureClasses()
import os ws = "c:/temp" for file in os.listdir(ws): if file.endswith(".shp"): print file
Could this script be expanded to list multiple file types?.
import os ws = "c:/temp" for file in os.listdir(ws): if file.endswith(".shp") or file.endswith(".dxf") or file.startswith("str"): print file
import os, glob # Delete all files that contain the word 'points' for file in glob.glob("*points*"): os.remove(file)
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.