Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In my SHP to GDB toolbox, I create a list of layers in MXD, then I check for those not broken I move them. Despite using ListBrokenDataSources I have errors like this:

Runtime error : [Error 3] Impossible trovare il percorso specificato: u'J:\20120208_Backup_disco_E\Archivio\ATLArete\Shape Atlarete 1-1-2008\miste.shp'

Translate:

Runtime error : [Error 3] Unable to find the specified path: u'J:\20120208_Backup_disco_E\Archivio\ATLArete\Shape Atlarete 1-1-2008\miste.shp'

Here is my code:

# Create a list of SHP in mxd 
    list = []
    df_list = arcpy.mapping.ListDataFrames (mxd)

    for df in df_list: 
        for fc in arcpy.mapping.ListLayers (mxd, "", df):
            if (fc.supports("DATASOURCE")) and (fc.dataSource.endswith(".shp")):
                        list.append(fc)
    print("List created")

    # Check for borken datasource
    for fc in list:
        if arcpy.mapping.ListBrokenDataSources(fc):
            list.remove(fc)
    print ("Broken data removed from list")

    # Move fc to gdb
    add_list = []
    for fc in list:
        fc_date = time.strftime("%Y%m%d", time.gmtime(os.path.getctime(fc.dataSource)))
        try:
            dsc = arcpy.Describe(fc)
            out_temp = '_' + fc_date + '_' + fc.name + '_' + fc_prj
            out_name = arcpy.ValidateTableName(out_temp)
            print ('Created ' + out_name + ' to ' + gdb_full_path)
        except:
            out_temp = '_' + fc_date + '_' + fc.name + '_' + 'UNKNOWN'
            out_name = arcpy.ValidateTableName(out_temp)
            print ('Created ' + out_name + ' to ' + gdb_full_path)
        arcpy.FeatureClassToFeatureClass_conversion(fc, fd_path, out_name)
        replace_name = fd_path + '\\' + out_name
        fc.replaceDataSource (gdb_full_path, "FILEGDB_WORKSPACE", out_name)
        print ('Replaced data source ' + out_name + ' in ' + gdb_full_path)


    # Create a new MXD
    new_mxd = os.path.splitext(gdb_full_path)[0] + '\\' + 'MXD' + '\\' +  time.strftime("%Y%m%d", mxd_date )+ '_' + (mxd_name)
    mxd.saveACopy(new_mxd)
    print ('Created new MXD ' + new_mxd + ' in ' + ws)
share|improve this question
    
@Mapperz: I don't get what you edited, can you be more clear? –  Luca Moiana Sep 6 '12 at 14:43
add comment

1 Answer 1

Not an answer but a screenshot of the posters request "@Mapperz: I don't get what you edited, can you be more clear? "

enter image description here

share|improve this answer
    
spelling required the edit –  Mapperz Oct 9 '12 at 13:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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