I'm struggling with deleting an mxd in a for loop. My code is:
import arcpy, glob, os, datetime, time from time import strftime for filename3 in glob.glob(os.path.join(folderPath, "*.mxd")): fullpath = os.path.join(folderPath, filename3) basename, filename2 = os.path.split(fullpath) mxd = arcpy.mapping.MapDocument(filename3) if os.path.isfile(fullpath): basename, filename2 = os.path.split(fullpath) (shortname, extension) = os.path.splitext(filename2) mxd.saveACopy(draftloc + "\\" + "SentToDraftOn(" + strftime("%d%b%y %Hh%Mm%Ss") + ")"+ "_" + shortname + extension) arcpy.Delete_management(mxd)
I'm trying to do some processing on each mxd in a directory and then I want to saveACopy to a new location and then delete the old mxd. I keep getting the following traceback error:
Object: Error in executing tool
I think it's an indentation thing, but I can't seem to figure it out. Can anyone suggest what I am missing?