Title: Exclude folder during scan?
Last modified: October 2, 2018

---

# Exclude folder during scan?

 *  Resolved [jacktester](https://wordpress.org/support/users/jacktester/)
 * (@jacktester)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/)
 * Is it possible to exclude a specific subfolder of the uploads directory.
 * I use WP All Import which stores all it’s import files in a /wpallimport folder
   in the uploads directory, there are some 20,000 files in there, mostly images,
   that are obviously not in the media library and Media Cleaner scans and lists
   them all.
 * It would be vastly more efficient if I could tell it not to bother scanning that
   particular directory in the first place.

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/exclude-folder-during-scan/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/exclude-folder-during-scan/page/2/?output_format=md)

 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10754584)
 * Hi,
 * It’s a bit complicated to do right now (UI-wise especially) but I am thinking
   of adding a simple option. If checked, it will scan everything. If not, it will
   only scan the folders YYYY-MM (the ones naturally created by WP to store upload
   images). Do you think that would fix most of your issue?
 *  Thread Starter [jacktester](https://wordpress.org/support/users/jacktester/)
 * (@jacktester)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10758824)
 * Hi Jordy
 * We don’t use the YYYY/MM folders, in hindsight this might have been a bad idea
   as we now have 177,000 files in our uploads folder, but we didn’t anticipate 
   that at the time and somewhat surprisingly it doesn’t appear to be causing any
   performance issues, as most pages on the website load between 600ms and 1200ms
   with Chromes browser cache disabled in DevTools.
 * That said I’m sure it may still be useful for some people who might be in a similar
   boat, as there are many plugins that store files in sub-folders of the uploads
   directory.
 * Would it also however not be possible to scan /uploads excluding sub-folders 
   that don’t have the YYYY/MM naming format. Presumably anything in the WordPress
   media library would either be in /uploads or in a YYYY/MM directory, anything
   else would likely be plugin related files? Naturally this would be best in the
   form a check-box as you say, as it would also be handy to be able to scan for
   files leftover by removed plugins.
 * In terms of a regex it would look like this: `^\/uploads(\/([0-9]{4})?\/([0-9]{
   2}))?$`
 *  [Christos Chatzaras](https://wordpress.org/support/users/cybercr33p/)
 * (@cybercr33p)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10760918)
 * Having thousands of files in a single directory will not make your website slower.
   But it will make slower other functions, for example doing a tar, zip or rsync
   in a directory with thousands of files will be slower.
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10769247)
 * [@cybercr33p](https://wordpress.org/support/users/cybercr33p/) is right 🙂 But
   excluding folders (or files) is indeed a feature that is missing to Media Cleaner.
 * Actually, I am thinking it would be good to have a regex for files and directories
   and to add examples in the documentation little by little. I guess that will 
   be the best way to go about it.
 *  Thread Starter [jacktester](https://wordpress.org/support/users/jacktester/)
 * (@jacktester)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10773890)
 * Thanks both, that’s good to know, I’ve been trying to find that out, but all 
   I could find were threads giving theoretical maximum numbers of files, and never
   an explanation as to what problems it may cause having more than that in a single
   folder.
 * We don’t perform ant other functions in the uploads folder anyway, so not too
   much of an issue by the sounds of it.
 * I worked around the issue that was affecting me by temporarily moving the files
   out of the directory, as they were just in relation to an importing plugin moving
   them out doesn’t affect anything unless someone tries to run the import.
 * But I think an option to either regex match folders you want to exclude from 
   the scan, or an option to include folders that you do, would be good, and possibly
   a simple checkbox option using the regex above for those less comfortable creating
   regexes?
 *  [mrfm](https://wordpress.org/support/users/mrfm/)
 * (@mrfm)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10827073)
 * Hi, new pro user here. Just wanted to say I would like this feature as well. 
   Thanks! 🙂
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10828117)
 * It has already been coded, and it will be part of the new version 🙂 Please try
   it, and let’s see how we can improve it. Cheers 🙂
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10845660)
 * Hi everyone! The new version is out. Please try the new filters, I am looking
   forward to your feedback 🙂
 *  [mrfm](https://wordpress.org/support/users/mrfm/)
 * (@mrfm)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10846469)
 * Great! Will try it. Just an idea but you might want to add an exclude example
   to your tutorial for people new to RegEx. I think the below should work:
 * ^\b([a-z0-9]+)\b(?<!exclude1|exclude2|exclude3)
 * adjusted from: [https://stackoverflow.com/questions/2078915/a-regular-expression-to-exclude-a-word-string](https://stackoverflow.com/questions/2078915/a-regular-expression-to-exclude-a-word-string)
 * Edit: Hmm I am getting a message ‘invalid regular expression’ from Media Cleaner
   Pro but the regex checks out on regex101.com. Any ideas?
    -  This reply was modified 7 years, 6 months ago by [mrfm](https://wordpress.org/support/users/mrfm/).
    -  This reply was modified 7 years, 6 months ago by [mrfm](https://wordpress.org/support/users/mrfm/).
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10846493)
 * [@mrfm](https://wordpress.org/support/users/mrfm/) What is the regexp you are
   using?
 *  [mrfm](https://wordpress.org/support/users/mrfm/)
 * (@mrfm)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10846498)
 * You can see example in my reply above. The error shows when clicking ‘Save Changes’
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10846508)
 * This works: /^\b([a-z0-9]+)\b(?<!exclude1|exclude2|exclude3)/
 *  [mrfm](https://wordpress.org/support/users/mrfm/)
 * (@mrfm)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10846663)
 * OK thanks! 🙂
 *  [mrfm](https://wordpress.org/support/users/mrfm/)
 * (@mrfm)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10851740)
 * This was quite tricky to figure out but I think this is working:
 * /^((?!exclude1|exclude2|exclude3).)*$/
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/#post-10854606)
 * Yes, it should 🙂 But what do you exclude actually? Do you really have a real-
   life example?

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/exclude-folder-during-scan/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/exclude-folder-during-scan/page/2/?output_format=md)

The topic ‘Exclude folder during scan?’ is closed to new replies.

 * ![](https://ps.w.org/media-cleaner/assets/icon-256x256.png?rev=2791576)
 * [Media Cleaner: Clean your WordPress!](https://wordpress.org/plugins/media-cleaner/)
 * [Support Threads](https://wordpress.org/support/plugin/media-cleaner/)
 * [Active Topics](https://wordpress.org/support/plugin/media-cleaner/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/media-cleaner/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/media-cleaner/reviews/)

 * 17 replies
 * 4 participants
 * Last reply from: [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * Last activity: [7 years, 6 months ago](https://wordpress.org/support/topic/exclude-folder-during-scan/page/2/#post-10858545)
 * Status: resolved