2

I have thousands of unattached images with no files. How do I delete them all quickly?

ls: cannot access wp-content/uploads/2014/09/jeep cherokee patriot-Ekza.jpg: No such file or directory

  • I ended up using SQL and shell commands to remove them all. I selected all the unattached attachments into a file, used a for loop to list then remove the file, then deleted the rows from the database. I wish I saved the SQL and command line. – Chloe Oct 16 '14 at 0:02
  • 1
    Could you please share the code you used? I am about to do the same thing. If you still have access to that database command line, then it would be in the history. – user658182 Apr 7 '17 at 13:27
  • I want to have this code as well, can you please share it? – That Brazilian Guy Mar 1 '18 at 15:25
2

That's a lot of unattached images. If you have couple of hundred images then you can delete them manually from media library.

1. Click 'Screen Options' at the top right and set 'Show on screen' to 200.
2. Click 'Apply'.
3. Click the checkbox just under 'Bulk Actions' to check all images on the page.
4. Select 'Delete Permanently' in the 'Bulk Actions' dropdown.
5. Click 'Apply'.

But if you have thousand of unattached images then it would be best to use a plugin. DNUI (Delete not used image) plugin will do that for you. It will let you delete tons of images from media library.

Or use DX Delete Attached Media

  • My dashboard looks like this, I don't see any screen options. – Suncatcher May 12 '18 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.