What I need to do is to move all the shapefiles in an mxd into a newly created gdb, checking prj, and update mxd reference.
I have ArcGIS 10 SP4, license ArcView.
I studied a bit of Python and get familiar with basic, then I copied some written code and pasted all together, attached is the code.
With some help from ESRI forum I ended up with the following script where I get an error in the arpy.SpatialReference line.
# Import system modules import arcpy from arcpy import env import os import traceback # Load required toolboxes... arcpy.AddToolbox("C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\ArcToolbox\\Toolboxes\\Data Management Tools.tbx") # Set environment settings env.workspace = "C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto\\GIS\\test" print("env.workspace completed successfully") #check GDB exist if os.path.exists("c:\\park\\test4.gdb"): arcpy.Delete_management("c:\\park\\test4.gdb") # Execute CreateFileGDB arcpy.CreateFileGDB_management("C:\\park", "test4") print("CreateFileGDB completed successfully") # Set local variables outWorkspace = "c:\\park\\test4.gdb" print("outWorkspace completed successfully") # Iterate def fcs_in_workspace(workspace): arcpy.env.workspace = workspace for fc in arcpy.ListFeatureClasses(): dsc = arcpy.Describe(fc) if dsc.spatialReference.name == "WGS_1984_UTM_Zone_32N": print os.path.join(workspace, fc, "prj: WGS_1984_UTM_Zone_32N") arcpy.FeatureClassToGeodatabase_conversion(fc, "c:\\park\\test4.gdb") print os.path.join(workspace, fc, "importaed in GDB") elif dsc.spatialReference.name == "Unknown": print os.path.join(workspace, fc, "UNKNOWN") #HERE I'D LIKE TO IMPORT THE SHP IN GDB ADDING "_UNKN" TO THE FEATURE NAME else: print os.path.join(workspace, fc, "DIFFERENT PRJ!") # Determine the new output feature class path and name outfc = os.path.join(outWorkspace, fc) # Set output coordinate system print "PRJ CREATED!" # Create a spatial reference object using a projection file outCS = arcpy.SpatialReference('WGS_1984_UTM_Zone_32N') print "outCS CREATED!" arcpy.Project_management(fc, outfc, outCS) print "PROJECTED!" for ws in arcpy.ListWorkspaces(): fcs_in_workspace(os.path.join(workspace, ws)) fcs_in_workspace("C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto\\GIS\\test")