Is there a way I can purge all unused files/assets via the file manager? I'd like to clean up some directories for a client? If not, is there a query I could use to find out which files are unused?


Adding a little more context, the files are used with a number of add-ons:

  1. Native file fields
  2. Matrix
  3. Wygwam
  • I think you need to expand this to get an accurate answer. How are your files output in your templates? ie are you only ever using native file fields, do you have images in wysiwyg fields? Are you using matrix etc etc?
    – Tom Davies
    Dec 17, 2012 at 16:42
  • More questions (sorry) - roughly how many files in the file manager, and how many entries in the site, lastly & how are the files output in templates (eg are you using a plugin to resize on output) - I will explain why these are relevant in my answer, promise!
    – Tom Davies
    Dec 17, 2012 at 17:18
  • ~1650 files, 1000 entries, and using CE Image to dynamically resize.
    – Siebird
    Dec 17, 2012 at 20:38
  • Did you find a solution?
    – paulcripps
    Jun 2, 2016 at 16:08

1 Answer 1


This will most likely involve building a custom PHP script to do this.

The first part of the script would do the audit to compile a list of all files currently in use in the various fields. You'd need to tell the script which columns hold the image data.

The second part of the script would run each file name against that list and delete the file from the filesystem if it's not present.

Once the script has run, you should purge your CE Image cache directory to remove all unused files. CE Image will regenerate newly re-sized files as needed.

Back up the database and all files before starting this process.

If you aren't able to write such a script yourself, there are many talented developers in the EE community who can. I have someone to suggest if needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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