def execute():
	doctypes_with_text_fields = frappe.get_all("DocField", fields=["parent", "fieldname"],
		filters={"fieldtype": "Text Editor"})

	done = []
	for opts in doctypes_with_text_fields:
		if opts in done:
			continue

		try:
			result = frappe.get_all(opts.parent, fields=["name", opts.fieldname])
		except frappe.SQLError, e:
			# bypass single tables
			continue

		for data in result:
			old_value = data[opts.fieldname]
			if not old_value:
				continue

			html = scrub_relative_urls(old_value)
			if html != old_value:
				# print_diff(html, old_value)
				frappe.db.set_value(opts.parent, data.name, opts.fieldname, html, update_modified=False)

		done.append(opts)
Fix relative urls for image src="files/" to src="/files/" in DocTypes with text editor fields
dataset/ETHPy150Open frappe/frappe/frappe/patches/v5_0/fix_text_editor_file_urls.py/execute