Trying to get this script to find all .tif and .shp files and reproject them as shown. Having trouble getting it to run.
import sys, arcpy, os
mypath = r'C:\input '
Images = []
arcpy.env.workspace = mypath
for ThisFile in os.listdir(mypath):
thisName,thisExt = os.path.splitext(ThisFile)
if thisExt.upper == ".TIF":
Images.append(ThisFile)
out_workspace = r'C:\output'
OutSR = arcpy.SpatialReference(26916)
for ThisFile in Images:
desc = arcpy.Describe(ThisFile)
SR = desc.spatialReference
if SR.factoryCode != 26916:
arcpy.ProjectRaster_management(ThisFile,out_workspace + "\\" + ThisFile,OutSR)
ShapeFiles = []
for ThisFile in os.listdir(mypath):
thisName,thisExt = os.path.splitext(ThisFile)
if thisExt.upper == ".SHP":
ShapeFiles.append(ThisFile)
for ThisFile in ShapeFiles:
desc = arcpy.Describe(ThisFile)
SR = desc.spatialReference
if SR.factoryCode != 26916:
arcpy.Project_management(ThisFile,out_workspace + "\\" + ThisFile,OutSR)
Solved! Go to Solution.
Instances of ".upper ==" should be changed to ".upper() ==" - you need to call the upper method that belongs to the string.
What's the error message?
After hitting "Enter", it simply returns to >>> without doing anything.
May have trouble with mypath backslash. Try mypath = r'C:\input '
I changed the input as shown. Still nothing.
Instances of ".upper ==" should be changed to ".upper() ==" - you need to call the upper method that belongs to the string.