HowTo:  Automate the process of deleting geoprocessing history

相关信息
Article ID: 41026
Software:
ArcGIS for Desktop Advanced 10.1
ArcGIS for Desktop Standard 10.1
Platforms:
Windows XP, Server 2003, Vista, Server 2008, Windows 7, Windows 8

问题描述
GIS administrators and managers sometimes need to delete geoprocessing history from a feature class' metadata. Instructions provided describe how to do this using a Python script.
已邀请:

EsriSupport

赞同来自:

解决方案
The following Python script automates the process of deleting the geoprocessing history for all feature classes stored inside and outside feature datasets within an ArcSDE geodatabase.

1. Modify the below parameters from the script according to the environment:
sdeconn 
remove_gp_history_xslt
out_xml

2.
#Import arcpy module
import arcpy, os, string


def RemoveGpHistory_fd(sdeconn,remove_gp_history_xslt,out_xml):
arcpy.ClearWorkspaceCache_management()
for fd in arcpy.ListDatasets():
arcpy.env.workspace = sdeconn + os.sep + fd
for fc in arcpy.ListFeatureClasses():

name_xml = out_xml + os.sep + str(fc) + ".xml"
#Process: XSLT Transformation
arcpy.XSLTransform_conversion(sdeconn + os.sep + fd + os.sep + fc, remove_gp_history_xslt, name_xml, "")
print "Completed xml coversion on {0} {1}".format(fd,fc)
# Process: Metadata Importer
arcpy.MetadataImporter_conversion(name_xml,sdeconn + os.sep + fd + os.sep + fc)
print "Imported XML on {0}".format(fc)


def RemoveGpHistory_fc(sdeconn,remove_gp_history_xslt,out_xml):
arcpy.ClearWorkspaceCache_management()
arcpy.env.workspace = sdeconn
for fx in arcpy.ListFeatureClasses():

name_xml = out_xml + os.sep + str(fx) + ".xml"
#Process: XSLT Transformation
arcpy.XSLTransform_conversion(sdeconn + os.sep + fx, remove_gp_history_xslt, name_xml, "")
print "Completed xml coversion on {0}".format(fx)
# Process: Metadata Importer
arcpy.MetadataImporter_conversion(name_xml,sdeconn + os.sep + fx)
print "Imported XML on {0}".format(fx)


if __name__== "__main__":

# Local variables:
sdeconn = "Database Connections\\CHILD_SAFARI_SQL.sde"
arcpy.env.workspace = sdeconn
remove_gp_history_xslt = "C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\Metadata\\Stylesheets\\gpTools\\remove geoprocessing history.xslt"
out_xml = "C:\\XML_out"
os.mkdir(out_xml)
RemoveGpHistory_fd(sdeconn,remove_gp_history_xslt,out_xml)
RemoveGpHistory_fc(sdeconn,remove_gp_history_xslt,out_xml)



创建及修改时间
Created: 3/25/2013

Last Modified: 8/6/2013
原文链接
http://support.esri.com/en/kno ... 41026

要回复问题请先登录注册