Import bulk pdf attachments and match with corresponding reference

Because somewhere along the line I incorrectly saved a library, I now have a libary full of references with 80% of the file attachments broken. After hours of discussing with customer support, my only solution is to manually add the attachments…again. That works fine for a few references but not close to 600. 

All of the references in my library that contain broken PDF attachments still list the PDF file name in the reference itself. All of those PDF files are housed in a single external (external to EndNote) folder. Programmatically, it should not be difficult to have some option to import the folder containing the PDF files and ask EndNote to parse the folder and match the file name in the folder with the appropriate reference containing an attachment with the corresponding file name. Thus re-attaching all of the broken PDF files to the appropriate reference. it’s a simple one-to-one matching. EndNote goes through each reference in the library, identifies references with broken attachments, grabs the attachment file name (in memory) already listed in the reference, searches the imported folder for the PDF file with matching filename, and then attaches said PDF file to the reference. A good database programmer should be able to write a script to accomplish this in less than an hour. This would help people who have somehow managed to end up with a library full of broken reference attachments from improperly exporting a library or saving a library copy.