Woohoo, new error.The script below:#Import python modules
import os, sys, string, glob, arcpy.mapping
#Set local variables
mxdLst = glob.glob('*.mxd')
mxdCnt = len(mxdLst)
####
#Place script in same folder as MXDs to get 'current working directory'
####
baseF = os.getcwd()
#Print how many mxd's found
print '\n' + 'Found ' + str(mxdCnt) + ' MXDs for exporting to PDF...'
print 'Directory: ' + baseF + '\n'
#For loop to process each mxd into a PDF
for mxds in mxdLst:
#outPDF = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf'
#print 'Exporting ' + mxds + ' -> ' + outPDF
mxd = 'r' + '\"' + baseF + '\\' + mxds + '\"' #mxd with fullpathname
#inMxd = arcpy.mapping.MapDocument(mxd) #Make current mxd in loop the mapdocument
#arcpy.mapping.ExportToPDF(inMxd, outPDF) #Export mapdocument to pdf
#print 'Done exporting: ' + outPDF
print mxd
del mxds
Outputs:Found 5 mxds for PDF exporting...
Directory: C:\Users\is0009\Desktop\temp
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.mxd"
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_2_17x11.mxd"
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_3_17x11.mxd"
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_4_17x11.mxd"
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_5_17x11.mxd"
...where I am trying to pass the above 'string' as my MapDocument.But when I modify the script to then use that string:#Import python modules
import os, sys, string, glob, arcpy.mapping
#Set local variables
mxdLst = glob.glob('*.mxd')
mxdCnt = len(mxdLst)
####
#Place script in same folder as MXDs to get 'current working directory'
####
baseF = os.getcwd()
#Print how many mxd's found
print '\n' + 'Found ' + str(mxdCnt) + ' MXDs for exporting to PDF...'
print 'Directory: ' + baseF + '\n'
#For loop to process each mxd into a PDF
for mxds in mxdLst:
outPDF = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf'
print 'Exporting ' + mxds + ' -> ' + outPDF
mxd = 'r' + '\"' + baseF + '\\' + mxds + '\"' #mxd with fullpathname
inMxd = arcpy.mapping.MapDocument(mxd) #Make current mxd in loop the mapdocument
arcpy.mapping.ExportToPDF(inMxd, outPDF) #Export mapdocument to pdf
print 'Done exporting: ' + outPDF
#print mxd
del mxds
Results in the following error from IDLE now:Found 5 MXDs for exporting to PDF...
Directory: C:\Users\is0009\Desktop\temp
Exporting Rural_OCP_map_1_17x11.mxd -> Rural_OCP_map_1_17x11.pdf
Traceback (most recent call last):
File "C:\Users\is0009\Desktop\temp\mxdloop.py", line 23, in <module>
inMxd = arcpy.mapping.MapDocument(mxd) #Make current mxd in loop the mapdocument
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins.py", line 443, in __init__
assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename")
AssertionError: Invalid MXD filename.
What is it that is making my MXD name invalid?Is it because I am not handling the slashes in the filepath name correctly and they are considered invalid characters?