From my collection of ArcGis 9.3 python scripts:
import arcgisscripting
gp = arcgisscripting.create(9.3)
Shape_A = "c:\\some\\path\\to\\shapefile.shp"
Shape_B = "c:\\some\\other\\path\\other_shapefile.shp"
Intersection = "c:\\output\\path\\output.shp"
gp.Intersect_analysis(Shape_A + ";" + Shape_B,Intersection,"ALL","#","INPUT")
You will need to change the paths to match your data - remember python uses the escape backslash \\
for a backslash or you can use the unix/linux forward slash in single eg. "c:/some/path/to/shapefile.shp"
.
Using a version 9.3 geoprocessor gp
you append the feature class names (full path) with a semi-colon in between see Intersect_analysis - also for the explanation of the parameters "ALL","#","INPUT"
.
If you want to do a folder full of feature classes matching up to another folder you can do it like this:
import sys,arcgisscripting
gp = arcgisscripting.create(9.3)
InFolder = sys.argv[1]
MatchFolder = sys.argv[2]
OutFolder = sys.argv[3]
gp.workspace = InFolder # set the workspace
FeatureClasses = gp.ListFeatureClasses() # get a list of feature classes
# step through the feature classes
for FC in FeatureClasses:
MatchFC = MatchFolder + "\\" + FC
# if the same name is in the match folder
if gp.Exists(MatchFC):
InterFC = OutFolder + "\\" + FC
# perform the intersection
gp.Intersect_analysis( FC + ";" + MatchFC,InterFC,"ALL","#","INPUT")
The sys.argv match up with the tool parameters (read Adding a Script Tool)