Save a copy of mxd

5691
3
Jump to solution
12-21-2015 09:24 AM
MitchHolley1
MVP Regular Contributor

Hello All,

I am trying to open an existing .mxd--> add some layers to it--> then save it to a new location.  I keep getting the same error over and over which is :

I've tried using arcpy.mapdocument.saveACopy() as well as shutil.copy().  But I get the same error. 

I'm sure it's a simple syntax error, but I've tried re-naming the file, changing the output location... and I still get the same error.

Any help is greatly appreciated.  Please excuse my elementary knowledge of Python and my ugly script!

0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor

Try changing your path references to r'C:\...' style. Your path may be getting escaped by the backslashes.

mxd = arcpy.mapping.MapDocument(r"C:\Users\holleym\Desktop\Projects\temp.mxd")

View solution in original post

3 Replies
DarrenWiens2
MVP Honored Contributor

Try changing your path references to r'C:\...' style. Your path may be getting escaped by the backslashes.

mxd = arcpy.mapping.MapDocument(r"C:\Users\holleym\Desktop\Projects\temp.mxd")

MitchHolley1
MVP Regular Contributor

Thanks so much @DarrenWiens!  It worked!

What exactly did that do?  Make it readable?

0 Kudos
DarrenWiens2
MVP Honored Contributor

The 'r' indicates raw string notation (see here). It says that the following string is not to be escaped by backslashes. In your example, '\t' is interpreted as 'tab' (see here for a list of escape sequences).