I'm trying to reproject a number of shapefiles representing contours from NAD_83_Albers to NAD_83_UTM_Zone_9N using arcpy.BatchProject(), but I have to use python/regex to preserve a particular file architecture.

The script works for all practical purposes, however one thing concerns me. When the script finishes, the XML file for the new shapefile points to the location of the original file as the source and lists the old projections instead of the new ones. The script appears to have simply copied the contents of the old XML file into the new XML instead of showing the proper values. When I go into the properties of the shapefile in Arc it says the projection is UTM rather than Albers as it should be, but the XML file does not line up with this.

Any ideas?

Here's my code.

import arcpy, os, re
rcont = re.compile(".*\contours")
inputDir = arcpy.GetParameterAsText(0)
outputDir = arcpy.GetParameterAsText(1)
for path, dirs, files in os.walk(inputDir):
  holder = path
  if rcont.match(holder):
    splitList = re.split("[\\\]", holder)
    cell = splitList[4]
    trimName = splitList[5]
    featureType = splitList[6]
    newDir = outputDir + "\\" + cell
    newDir2 = newDir + "\\" + trimName
    newDir3 = newDir2 + "\\" + featureType
    if not os.path.exists(newDir):
    if not os.path.exists(newDir2):
    if not os.path.exists(newDir3):
    arcpy.env.workspace = holder
    fileList = []
    for files in arcpy.ListFeatureClasses():

    res = arcpy.BatchProject_management(fileList, newDir3, sr)
    if res.maxSeverity == 0:
        arcpy.AddMessage("projection of all datasets successful")
        arcpy.AddMessage("failed to project one or more datasets")

I think your issue has been addressed here. As given in the second paragraph,

For example, if the metadata describes the item as having one projection but the item's projection has changed since the last automatic update, the old projection information in the metadata will be replaced with the new projection information.

Basically geoprocessing tools are lazy when it comes to updating XML and you need to incorporate Synchronize Metadata tool with OVERWRITE option to your script to have everything updated. Additionally, I really appreciate your concern on having an up-to-date/correct metadata!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.