Detect broken links with arcpy?

2074
20
03-07-2014 10:59 AM
TracyDash
New Contributor III
Hi,

I adapted some code I found online to search for broken (moved or renamed) hyperlinks in a shapefile. It should write all broken links to a text file, but instead it is writing ALL the hyperlinks to the text file. Any advice on what to change? I know extremely little about python.

Also, I have arcmap 10.1

thank you!

import arcpy
import os

fc = r" C:\Users\GIS\Documents\TEST 2-25\project_test.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):
            pass
        else:
            f = open(r"C:\Users\GIS\Documents\brokenlinks.txt","a")
            f.write(Roll + os.linesep)
            f.close()
Tags (2)
0 Kudos
20 Replies
TracyDash
New Contributor III
Ahh yes I see. That's really too bad. I'll post if I ever find a solution.

But thanks for all your help! Much appreciated.
0 Kudos