I have a script that looks through datasets in a geodatabase and copies a mxd document to a folder. The programs works, however it is saving the map documents to my desktop and not the specified folder on my desktop (PATH2). This is the code I have so far:

import arcpy
import os
PATH1 = r"C:\Users\Daimon Nurse\Desktop\DFMPROJECT\DFM.gdb"
PATH2 = r"C:\Users\Daimon Nurse\Desktop\DFMPROJECT\"
arcpy.env.workspace = PATH1

zones = arcpy.ListDatasets("Zone*")

for zone in zones:
    mxd = arcpy.mapping.MapDocument(r"C:\Users\Daimon Nurse\Desktop\DFMPROJECT\Complete Final Capstone Map\Complete Z2 Campus Map_Landscape1.mxd")
    print zone
    mxd.saveACopy(PATH2 + zone)
  • I realised its recognising the path only as r""C:/Users/Daimon Nurse/Desktop" and using DFMPROJECT as part of the name of the map document and not as the folder path Jan 9, 2015 at 20:38
  • You just need to add another forward slash to the PATH2.
    – ianbroad
    Jan 9, 2015 at 20:41
  • Do you mean as the edit I made to PATH2? Jan 9, 2015 at 20:51
  • Personally, I would replace the backslash before a close-parenthesis with a forward slash, as I get errors in my IDE with \", even with the r at the start of the string. Jan 9, 2015 at 20:55

1 Answer 1


I would set the PATH2 variable this way:

PATH2 = r"C:\Users\Daimon Nurse\Desktop\DFMPROJECT"

And then try this insead of mxd.saveACopy(PATH2 + zone):

newmxd = os.path.join (PATH2, zone + ".mxd")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.