wittle

Compress Project Script for Arc10

Discussion created by wittle on Oct 20, 2010
Latest reply on Nov 17, 2010 by 1stAmerican
Hello,

Can anybody correct the following Python script so that it will run? The basic idea is simple, it saves a copy, deletes the original, renames the copy to the original name and then opens the new (smaller) project file.

try:

    #Imports
    import arcpy, os

    #Definitions
    mxd = arcpy.mapping.MapDocument("CURRENT")
    #file_path = os.path.
    file_path = os.path.dirname(mxd)
    file_temp = os.path.basename(Input).rstrip(os.path.splitext(Input)[1])
    file_name = file_path + file_temp  ".mxd"
    file_name_temp = file_path + file_temp + "_Copy.mxd"

    #Save a copy
    mxd.saveACopy(file_name_temp)
    close(mxd)
    os.rename(file_name_temp, file_name)
    open(file_name)

#Output Errors Report
except Exception as e:
    print e.message
    # If using this code within a script tool, AddError can be used to return messages
    #   back to a script tool.  If not, AddError will have no effect.
    arcpy.AddError(e.message)

However, it currently doesn't work and python doesn't seem to allow step by step debugging.

Thanks

Outcomes