GilvarryCW

Visual C++ Runtime Error

Discussion created by GilvarryCW on Oct 1, 2012
Latest reply on Oct 1, 2012 by mzcoyle
I'm trying to export a few dozen map files to Jpegs using a script, which I've listed below, but every time I run the script I get a "Runtime Error" on the 5th time through the for loop. This happens on the " arcpy.mapping.ExportToJPEG" line regardless of the file it's working on. I've done some researching and can't figure out what I need to fix, is there something I can do?

Direct = ["C:/a bunch of directories/"]

#Get JPEGS from ArcGIS
path = ''
destpath = "S:/temp/"
destination = ''

for line in Direct:
    path = str(line)
    print path
    listing = os.listdir(path)
    for infile in listing:
        
        #get file extension 
        ext = os.path.splitext(infile)[-1].lower()
        print ext

        #Check if a map file
        if ext == ".mxd":
            curfile = path + infile
    
            mxd = arcpy.mapping.MapDocument(curfile)
            mapName = infile.rstrip('.mxd')
        
            project = destpath + mapName + ".jpg"

            arcpy.mapping.ExportToJPEG(mxd, project, resolution = 200)
            del mxd


Thanks for any help!

Attachments

Outcomes