ryan Posted August 3, 2012 Share Posted August 3, 2012 This module goes through all of your /site/assets/files/ directories and removes those that have no files in them. http://modules.proce...ean-empty-dirs/ Pages with file/image fields require a directory, so you should expect that some of the removed directories will be re-created by these pages. As of today, ProcessWire no longer creates directories for all pages, so this module is mostly useful to existing sites rather than future sites. I am listing it as "alpha" just because I've only tested on my own sites. Once I get confirmation from others that it also worked well for them, I will change its status to stable. Until it is considered stable, I suggest only running it in dev/test environments (not that it does anything dangerous, but just a good practice). 6 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted August 3, 2012 Share Posted August 3, 2012 This is great ryan! Will test it next week, this weekend no computer for me Link to comment Share on other sites More sharing options...
Pete Posted August 5, 2012 Share Posted August 5, 2012 3,819 folders reduced to 1,128 - muuuuch better I'm sure some will re-surface as my files section template allows either an external URL or a file as well as an optional screenshot, but I guess they're not updated often past the initial page creation. As you say in the other thread ryan, this could well be run every so often to tidy things up. I guess a nice addition could be to tie it in with the LazyCron module to make that automated on a weekly/monthly basis. Link to comment Share on other sites More sharing options...
ryan Posted August 6, 2012 Author Share Posted August 6, 2012 As you say in the other thread ryan, this could well be run every so often to tidy things up. I guess a nice addition could be to tie it in with the LazyCron module to make that automated on a weekly/monthly basis. If you are running the latest commit of ProcessWire, there's not really any reason to run this module more than once. And when you start a new site today or in the future (using the latest version of PW), then there's no need to run this module ever. I think this module would only be worthwhile as a recurring maintenance task if you are running an older version of ProcessWire. The only other situation I can think of is if you had files fields on some pages and later removed the files fields, the directories would still remain as long as the page existed, and this module would remove them. Link to comment Share on other sites More sharing options...
Peter Falkenberg Brown Posted April 7, 2013 Share Posted April 7, 2013 Hi Ryan, I'm making progress on my first PW site. I'm very pleased, so far! I'm replicating a structure I had done in MODX, and it's an interesting process. On this issue of "Pages with file/image fields require a directory" -- what about the scenario of a site with many thousands of articles, where the article pages have the image field, but perhaps only 50% of the articles have actual images? I would think that it would be much, much better to only create a directory when an image is attached to the page, and when it's deleted, then remove the image and the directory. It seems inefficient to have thousands of empty directories. Also, wouldn't that add to the max number of inodes, perhaps causing an issue? Thanks! Peter 1 Link to comment Share on other sites More sharing options...
teppo Posted April 7, 2013 Share Posted April 7, 2013 @Peter: you might want to check discussion about this in another thread (linked by Pete earlier), starting from here: http://processwire.com/talk/topic/992-problem-with-assetsfiles-folder/?p=14452. A bit further down that thread there's a post from Ryan where he explains why file directories behave like they do. 1 Link to comment Share on other sites More sharing options...
WillyC Posted April 7, 2013 Share Posted April 7, 2013 m.rbrown module this you.enjoy when have dirs of many of.witch you.no desire http://modules.processwire.com/modules/page-clean-empty-dirs/ Link to comment Share on other sites More sharing options...
Peter Falkenberg Brown Posted April 14, 2013 Share Posted April 14, 2013 Dear Teppo and WillyC, Thanks: I'll check that thread out. Peter Link to comment Share on other sites More sharing options...
wbmnfktr Posted September 27 Share Posted September 27 On 8/3/2012 at 6:37 PM, ryan said: As of today, ProcessWire no longer creates directories for all pages, so this module is mostly useful to existing sites rather than future sites. So... I just used this module in ProcessWire 3.0.241 and it works just perfect. Yet the above statement seems to be not correct anymore. Opened up some pages and I find a truck load of new empty directories in /site/assets/files/ again. Is it because the image field of those pages has a fallback image defined or did the default behaviour in ProcessWire change in those regards in the last 12 years? Wouldn't consider this as a bug. Just curious. 2 Link to comment Share on other sites More sharing options...
cb2004 Posted September 29 Share Posted September 29 @wbmnfktr I have also noticed the same over the years, but I thought nevermind, I have this module. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now