Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have zero experience with python but am trying to search for broken hyperlinks in a large gdb (temporarily converted to a shapefile)-

Used code from a previous question (Hyperlink broken path - python check) and adapted it to fit my problem (didn't know if I could ask a new question on that post...)

import arcpy
import os

fc = r"G:\GISDATA\misc\project_arcpy.shp"
fields = ["PROJECT_DW"]

with arcpy.da.SearchCursor (fc,fields) as cursor:
for row in cursor:
    Roll = str(row[0])
    if os.path.exists(Roll):
        f = open(r"C:\Users\GIS\Documents\brokenlinks.txt","a")
        f.write(Roll + os.linesep)

Instead of writing broken hyperlinks to my text file, it writes all they hyperlinks to the file...any advice?

share|improve this question
Could you provide more details on what defines a broken hyperlink? – Aaron Mar 6 '14 at 16:54
What version of ArcGIS for Desktop are you using? Either way I think the key will be to use a Search Cursor to look up where the Hyperlink field is pointing and then use arcpy.Exists() to see if that location exists. – PolyGeo Mar 7 '14 at 8:39
Broken hyperlink= hyprelink won't work anymore because the name was changed by a coworker or the document no longer exists. – Tracy Mar 7 '14 at 16:13
PolyGeo=using arcgis 10.1. OK, thanks...I will try to put that into code.. – Tracy Mar 7 '14 at 16:13
@Tracy: Is the field "PROJECT_DW" contains web link or network/local disk path or both? – Surya May 8 '14 at 21:54

Your Answer


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

Browse other questions tagged or ask your own question.