I run the script that I created below, but when it is completed and I check the FC tables, nothing has changed.
The script iterates through each feature class of a database and then iterates through each row of that feature class to check if the first 4 characters of the string record under the field "Photo1" are eqaul to "http". If the characters are "http", then it rewrites the field with the new given path. In other word, if there is already a web link, it rewrites it. This is because some rows do not have links in them.
import arcpyimport osarcpy.env.workspace = arcpy.GetParameterAsText(0)parish = arcpy.GetParameterAsText(1)field = 'Photo1'path = r"http://website.ca.gov/Photos"for fc in arcpy.ListFeatureClasses(): rows = arcpy.UpdateCursor(fc) for row in rows: photolink = str(row.getValue(field)) if photolink[0][:4] == "http": photolinkMod = photolink.split(r'/') photo = len(photolinkMod) - 1 row.setValue(field, os.path.join(path, parish, photo)) rows.updateRow(row)del row, rows
أكثر...
The script iterates through each feature class of a database and then iterates through each row of that feature class to check if the first 4 characters of the string record under the field "Photo1" are eqaul to "http". If the characters are "http", then it rewrites the field with the new given path. In other word, if there is already a web link, it rewrites it. This is because some rows do not have links in them.
import arcpyimport osarcpy.env.workspace = arcpy.GetParameterAsText(0)parish = arcpy.GetParameterAsText(1)field = 'Photo1'path = r"http://website.ca.gov/Photos"for fc in arcpy.ListFeatureClasses(): rows = arcpy.UpdateCursor(fc) for row in rows: photolink = str(row.getValue(field)) if photolink[0][:4] == "http": photolinkMod = photolink.split(r'/') photo = len(photolinkMod) - 1 row.setValue(field, os.path.join(path, parish, photo)) rows.updateRow(row)del row, rows
أكثر...