Solved! Go to Solution.
import os import arcgisscripting # Create the geoprocessor object gp = arcgisscripting.create(9.3) shp = r"C:\Dan\search_cursor.shp" brokeList = [] # <- you need a list #Create search cursor rows = gp.SearchCursor(shp) row = rows.Next() while row: # grab the item values you are interested in pathString = row.<<WHATEVER THE PATH FIELDNAME IS>> theFID = row.FID # see if the link path is valid if not os.path.exists(pathString): # append the FID of bad links to the list brokeList.append(theFID) row = rows.Next() if len(brokeList) > 0: print "Broken links found!" # write the list to a file txt = open(r"C:\Dan\demo.txt", 'w') for broke in brokeList: txt.write(str(broke) + "\n") txt.close() print 'DONE'
if not os.path.exists(pathString): brokeList.append(theOID)
import os import arcgisscripting # Create the geoprocessor object gp = arcgisscripting.create(9.3) #Create search cursor shp = "C:\Dan\search_cursor.shp" rows = gp.SearchCursor(shp) row = rows.Next() fields = gp.ListFields(shp) if not os.path.exists(shp): brokeList.append(path,"demo.txt")
import os import arcgisscripting # Create the geoprocessor object gp = arcgisscripting.create(9.3) shp = r"C:\Dan\search_cursor.shp" brokeList = [] # <- you need a list #Create search cursor rows = gp.SearchCursor(shp) row = rows.Next() while row: # grab the item values you are interested in pathString = row.<<WHATEVER THE PATH FIELDNAME IS>> theFID = row.FID # see if the link path is valid if not os.path.exists(pathString): # append the FID of bad links to the list brokeList.append(theFID) row = rows.Next() if len(brokeList) > 0: print "Broken links found!" # write the list to a file txt = open(r"C:\Dan\demo.txt", 'w') for broke in brokeList: txt.write(str(broke) + "\n") txt.close() print 'DONE'