Over time working on a local and development server I've accumulated some junk in my wp-content/uploads folder which are not in the database. The folder and database entry are fairly large and so I was wondering if there was a plugin or way to do some type of "garbage collection" and delete items in the uploads folder which are not in the media library.

  • I am looking for a plugin that could do that as well. It's very doable, the user would just have to check everything before confirming the deletion. – TigrouMeow Jun 6 '12 at 9:01
  • Might also be cool to "move" the files to another directory and then move them back as they are requested (i.e. the 404 trigger) – cwd Jun 8 '12 at 18:21

There is no easy way to do this. You could query the WP database for wp_posts that are media uploads and then run a script to match those again the files in the uploads folder, but even this would be a little shaky.

  • This is also a security issue as it will not show up foreign files in uploads directory. – Third Essential Designer Dec 30 '16 at 9:45

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.