I am trying to take the guts of this code (Batch convert ArcGIS 9x files to 10) and build it into a tool that we can more flexibly use and share around our organization. I think I'm almost there but when I run the tool as a script in Arc, nothing happens. Thoughts? Thanks for your help. I'm fairly new to Python but am pretty good on where the guts of it all is.
mxdinloc is set to a folder
mxdoutvers is set to a string - value list where the list choices are (10.1, 10.0, 9.3, 9.2) - no quotes
EDIT: I ran through, got it working and wanted to share the final bit that I brought into my Script Toolbox:
#import modules
import arcpy
import os
import glob
#set parameters for inputs
mxdinloc = arcpy.GetParameterAsText(0)
mxdoutvers = arcpy.GetParameterAsText(1)
#set the values for input versions of ArcMap
if mxdoutvers == "10.1":
version = "10.1"
suffix = "_(10.1)"
elif mxdoutvers == "10.0":
version = "10.0"
suffix = "_(10.0)"
elif mxdoutvers == "9.3":
version = "9.3"
suffix = "_(9.3)"
elif mxdoutvers == "9.2":
version = "9.2"
suffix = "_(9.2)"
for pathname, directories, filenames in os.walk(mxdinloc):
for filename in filenames:
if filename.lower().endswith(".mxd"):
print "\nUpdating: " + filename
mxd = arcpy.mapping.MapDocument(mxdinloc + "\\" + filename)
filename, ext = os.path.splitext(mxdinloc + "\\" + filename)
print filename
if mxd.dateSaved:
print mxd.dateSaved
mxd.saveACopy(filename + suffix + ext, mxdoutvers)
currentMxd = filename + suffix + ext
mapDoc = arcpy.mapping.MapDocument(currentMxd)
print "Updated: " + filename + "\n"
else:
print "\n" + filename + " is not a MXD and was not updated. \n"