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?
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}))?$
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.
@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.
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?
Hi, new pro user here. Just wanted to say I would like this feature as well. Thanks! 🙂
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 🙂
Hi everyone! The new version is out. Please try the new filters, I am looking forward to your feedback 🙂
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
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 4 years, 11 months ago by
mrfm.
-
This reply was modified 4 years, 11 months ago by
mrfm.
@mrfm What is the regexp you are using?
You can see example in my reply above. The error shows when clicking ‘Save Changes’
This works: /^\b([a-z0-9]+)\b(?<!exclude1|exclude2|exclude3)/
This was quite tricky to figure out but I think this is working:
/^((?!exclude1|exclude2|exclude3).)*$/
Yes, it should 🙂 But what do you exclude actually? Do you really have a real-life example?