These are MySQL statements to bulk delete all WordPress attachments of a specified modified date in the WordPress database. Both steps are needed to remove not only the attachments, but also the postmeta which is attached to the parent post. This is a clean way to get rid of attachments without leaving behind dangling postmeta.
In this example, I use a wildcard (LIKE ‘2014-%’) for the date. This example will delete all attachments that have the year 2014 as the date. You can change the ‘2014-%’ in both steps to meet your needs.
Warning: Use this at your own risk. You may accidentally delete items that you do not intend to delete.
STEP 1
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT id FROM wp_posts WHERE post_modified LIKE '2014-%' AND post_type = 'attachment' )
STEP 2
DELETE FROM wp_posts WHERE post_modified LIKE '2014-%' AND post_type = 'attachment'
Questions and Comments are Welcome