Here is the situation: I have an automated script that upload attachments and link each attachment to a specific post. By mistake, the script run multiple times and I have the following
More than one attachment post in the Media library for a single file (the different attachment posts have the same File URL).
One of these attachment is actually attached to the post.
What I want to do is obviously is clean up the media library. I need to remove the attachment post without removing the file, and also make sure that I don't remove the ones that are actually attached to their posts.