for attach in attachments: # Check to see if this file is attached to the one we are looking for if not attach in current_attachments: count = count + 1 save_url(attach, document["doctype"], document["name"], "Home/Attachments") frappe.msgprint("Attached {0} files".format(count))...