I have created a system that sends the photos I put in the "Instagram" folder on the desktop directly to the Apple Photos app. I used Apple Shortcuts to do this. I automated this system using Keyboard Maestro. If I put a single photo in the Instagram folder, the system works fine. If I put more than one photo in the Instagram folder, Keyboard Maestro sends multiple copies to Apple Photos. Two photos become four photos, three photos become nine photos. How can I solve this problem?
Your macro is triggered once for each item added to the folder (adding a folder of files is only one item, though).
Your Shortcut processes all the files in that folder when it runs.
So adding two photos results in two executions of the macro and tow executions of the Shortcut -- each of which copy both files.
A quick fix could be to add a "Semaphore Lock" action at the start of your macro, set to a 1/100th of a second timeout and no notification. That'll stop the second/third/fourth/... instances of your macro from running the Shortcut because the first instance is still running.
But there's a chance you could add a second set of files while the Shortcut is processing the first and the semaphore lock is still in place. So a better solution would be to only handle one file at a time in the Shortcut, collecting that file path from the macro's %TriggerValue% and passing it to the Shortcut via the action's "With input from" option.