This is an old problem with a new twist. I need to take map packages and extract all of the temp data into a geodatabase using feature class to feature class. I need a good work around for getting rid of spaces in baseNames before sending them through arcpy.Desribe(x).baseName there are simply too many files in too many temp locations to do this the hard way. Here is my naming script, before I throw my feature class to feature class function script:
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
lyrs = arcpy.mapping.ListLayers(mxd)
for layer in lyrs:
name = arcpy.Describe(layer).baseName
name = name.replace("-", "_")
#name = name.replace(" ", "_")
layer.name = name
print name
arcpy.RefreshTOC()
Obviously the name.replace(" ", "_") isn't going to work because it is after the arcpy.Describe function. Is there a way I can use arcpy to make a list of the layers and use that list with os to access each layer in a loop to change the filename? One problem with this solution is that half of the mpk files are in a geodatabase and half are lone shape files. Obviously those in a gdb are in correct formatting though.