Script Error: Populating mxd document properties with arcpy.mapping module

Discussion created by jameskellough on Aug 25, 2011
Latest reply on Aug 25, 2011 by jameskellough
Hi folks,

I am new to the arcpy module at version 10. I have a number of mxd's with the same theme that will ultimately have either the same or very similar document properties. To save time typing, I want to write and run a script from the python window to automatically populate each mxd's document properties. This was pretty easy up until I wanted to populate the Title property with the mxd's name. After searching the forums and other online sources it seems the best way to do this is by parsing the filename out of the file path. I found some code samples to help me do this but can't get them to work (see highlighted code below) any help a more proficient python scripter can provide would be greatly appreciated.

Here is my code. I am having trouble making the highlighted code work; if I remove it from the script all else works just fine.

import os
mxd = arcpy.mapping.MapDocument("CURRENT")
P = mxd.filePath
mxd.title = P
mxd.summary = "blah,blah, blah."
mxd.author = "James Kellough"
mxd.credits = "My Company"
mxd.description = "blah, blah, blah"
mxd.tags = "Script, Python, Arcpy"
del mxd

Thanks kindly,

James Kellough