I couldn't get the os.walk portion of the code you provided to get to the jpgs. If I ran that portion of the script to test it (left out the cursor portion) it would iterate a folder in that same directory that had a jpg, but then stop there. It didn't find any other jpgs. So I changed those lines to this:
ws = r'C:\path\to\jpegs\root'
jpgs = {}
for dirName, subdirList, fileList in os.walk(ws):
for fname in fileList:
jpgs[fname[:-4]] = os.path.join(dirName,fname)
Anyway, thanks to all of your help this does what I want:
import arcpy, os
ws = r'C:\path\to\jpegs\root'
jpgs = {}
for dirName, subdirList, fileList in os.walk(ws):
for fname in fileList:
jpgs[fname[:-4]] = os.path.join(dirName,fname)
fc = r'pathto\Projects\DOT_SignInventory\Data.gdb\WCDOT_Signs'
fields = ['OID@', 'Post_Number', 'Photo']
with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
try:
row[2] = jpgs[row[1]]
cursor.updateRow(row)
except KeyError:
print("No photo for: {}".format(row[1]))
del cursor