WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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