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

I have massive number of files in my uploads folder. Is there a way of identifying those which are not linked to any post?

Note: some of those files are manually copied to uploads folder not via "media library"

share|improve this question
up vote 2 down vote accepted

The easiest way would probably be:

1) perform a WordPress XML export ( Dashboard -> Tools -> Export )

2) import into a clean WordPress install ( Dashboard -> Tools -> Import )

At this point, everything in the /uploads directory of the clean install is attached. You can now:

3) backup/delete your original /uploads directory

4) copy over the /uploads directory from the clean install

share|improve this answer
Would it be possible to automatically import all manually copied files (as if they were imported via media library)? So I can use built-in feature to detect unlinked files? – user3047 Apr 19 '11 at 20:04
I don't understand your question. – Chip Bennett Apr 19 '11 at 20:08
ok. At the moment half of the media files are imported regularly via medial library. I like that. I can go to dashboard->media->un_attached and manage my media files easily (find unattached files)... but the other half is manually copy/pasted into uploads folder so wordpress can't see them... so I can't use the un_attached option – user3047 Apr 19 '11 at 20:17
This plugin lets you recreate your media library from uploads folder wordpress.org/extend/plugins/add-from-server – user3047 Apr 19 '11 at 21:25
Now I need to get rid of duplicate attachments... hell – user3047 Apr 19 '11 at 21:49

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.