media library – How can I delete duplicate `*-1.jpg` images?

If you want to delete files from the Media Library, then you need to delete both the database entry (attachment post) and the actual file (files to be more precise as there might be one or more scaled versions of the same image file depending on your setup).

You can do these both actions for example with wp_delete_attachment(),, which of course requires you to first know the IDs of the attachment posts, which have -1.jpg on the file name.

To find these IDs you’ll need to query the yourprefix_posts database table. You’ll need to use $wpdb as you need to query the guid column to find attachment posts with the matching file name as the file path/url is stored in that column – if I remember correctly.