How-To Bulk Delete Media in WordPress- Mass Delete Tutorial

Start

Bulk Delete Media in WordPress: Overview

When viewing the Media Library, you can use the “Bulk Actions” drop-down that appears in the “List” view or the “Bulk Select” button that appears in the “Grid” view to bulk delete media in WordPress.

To bulk delete media in WordPress, open the “Media Library” by clicking the “Media” button within the WordPress Admin Panel. If you are using the “Grid” view of the Media Library, click the “Bulk Select” button. Then click each media item in the Media Library that you want to delete to mark them with a checkmark in their upper-right corners. After checking the items to delete, click the “Delete Selected” button that appears above the media items within the Media Library to delete them. You can click the “Cancel Selection” button to cancel the bulk deletion and return to the normal view of the Media Library, if desired.

If using the “List” view of the Media Library, click the checkbox to the left of each media item you want to bulk delete. You can select all media items on a page by clicking the checkbox at the top of the checkbox column, to the left to the word “File,” at the top of the screen. Then use the “Bulk Actions” drop-down to select “Delete Permanently.” Then click the “Apply” button to permanently delete the selected media items.

Bulk Delete Media in WordPress: Overview

  1. To use the “Bulk Actions” drop-down that appears in the “List” view or the “Bulk Select” button that appears in the “Grid” view to bulk delete media in WordPress when you are viewing the Media Library, open the “Media Library” by clicking the “Media” button within the WordPress Admin Panel.
  2. If you are using the “Grid” view of the Media Library, click the “Bulk Select” button.
  3. Click each media item in the Media Library that you want to delete to mark them with a checkmark in their upper-right corners.
  4. Click the “Delete Selected” button that appears above the media items within the Media Library to delete them.
  5. To cancel the bulk deletion, click the “Cancel Selection” button to return to the normal view of the Media Library.
  6. If using the “List” view of the Media Library, click the checkbox to the left of each media item you want to bulk delete.
  7. To select all media items on a page, click the checkbox at the top of the checkbox column, to the left to the word “File,” at the top of the screen.
  8. Use the “Bulk Actions” drop-down to select “Delete Permanently.”
  9. Click the “Apply” button to permanently delete the selected media items.

There are two options to completely delete all media in your WordPress media library in bulk. One using the WordPress admin page (safer) and one performing direct deletions using FTP/SSH/PHPMyAdmin, which is good if you have thousands of items to delete.

Following the below steps can be very dangerous. I don’t recommend doing this on a production/live website. Be sure to backup everything first.

Using WordPress Admin

You can delete up to 200 items in your media library at a time using this method (now up to 999 with the latest version of WordPress). First, log in to your admin and go to the media library. Change the view to “line details”:

Then click the Screen Options button (near the top), which will be visible now:

Change the number of items per page to 200 and hit Apply (newer versions of WordPress accept up to 999, so try that first):

Now you will have many more items displayed per page of the media library. Use the “all” checkbox and bulk option to delete a full page of images at a time:

Using FTP/SSH & Database

This method allows you to delete all items in your media library at once. Be sure to backup your database prior to doing this.

Each file in your media library has one row in the `wp_posts` table and two rows in the `wp_postmeta` table. Learn more about how WordPress stores media library entries in the database here. You can delete them all in bulk using these commands:

DELETE FROM `wp_posts` WHERE `post_type` = "attachment";
DELETE FROM `wp_postmeta` WHERE `meta_key` = "_wp_attached_file";
DELETE FROM `wp_postmeta` WHERE `meta_key` = "_wp_attachment_metadata";

You can run those in PHPMyAdmin or by logging into MySQL through SSH. I won’t cover how to log in to either of those platforms here. If you’re unsure, ask your hosting provider.

Files
Now that the database entries are gone, use FTP or SSH to delete the files themselves. They reside in your uploads folder:

/wp-content/uploads
Please note that many plugins add their own folders to the uploads folder. You probably don’t want to delete those. By default WordPress stores your uploaded media library files in /year/month/ folders. There is a bulk delete media wordpress plugin as well, but better to avoid.

WooCommerce Product Images

If you have WooCommerce you may find that your products still think they have an image and gallery images after doing the above steps. To remove all image remnants from the WooCommerce products, you’ll need to run these SQL commands as well:

DELETE FROM `wp_postmeta` WHERE `meta_key` = "_thumbnail_id";
UPDATE `wp_postmeta` SET `meta_value` = NULL WHERE `meta_key` = "_product_image_gallery";

bulk delete media wordpress plugin , 

wordpress delete unattached media ,

delete unused images wordpress plugin , 

wordpress media library delete file , 

how to remove media in wordpress ,

how to remove unattached media in wordpress ,

woocommerce delete all product images ,

wordpress delete pictures

Gurminder

Gurminder is a political scientist and critical thinker based in Australia. He regularly blogs on constructive criticism.