• I built a site several years ago and made the mistake of turning off the “Organise my uploads into month- and year-based folders” setting. That was courtesy of the Core Teaks plugin, which I used at the time for new setups.

    In fairness, there’s no warning next to this setting about how much of a problem this can become on sites that upload a large number of media files. There should be a warning, because this folder is now unmanageable.

    The site has grown over the years and there’s now 98,000 images in the Uploads folder. This isn’t helped by the fact that, unbeknown to me, the theme creates 19 (yes, you read correctly, 19) different sizes of the same image with each upload. None of them are being used anywhere, apart from full size, but this has multiplied the number of files in that folder by 19.

    I have now re-enabled the month and year setting, but it’s too late. The folder simply can’t be accessed by FTP due to the number of files within it, and even accessing it via the host’s file manager takes ages and I’m unable to archive the folder, the operation simply times out. I’m restricted by the file manager to selecting 1000 files at a time, so even breaking into several archives in unrealistic.

    I only discovered this today because the site needs updating, so I created a MySQL dump and then tried to create a dump of the web files, but whenever I try to compress the Uploads folder, it times out.

    What can be done? Ideally I’d like to rearrange the folder into years and months and move all images into the right folders without breaking the URLs. All media manager plugins I found simply create “virtual” folders for the backend, without actually moving the source files, which doesn’t help me. The site badly needs updating, but I’m stuck at the export stage because of this crazy Uploads folder.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I would try this old plugin by one of the admins here:
    https://www.ads-software.com/plugins/dynamic-image-resizer/
    which checks for a 404 and generates the image at that time. That means you can delete all the generated images. I would use a command line and target the dimensions that are at the end of the file names.
    You may have to ask your host for help to accomplish the deletion.
    Or you could modify a plugin like Regenerate Thumbnails, in order to do the correct deletion of the generated images and then stop (not regenerate). Actually, that plugin might help you with the renaming of the images since it does update the content for the new image names (since the dimensions can change). It might put them in the various date folders if you have that option on now.
    Before trying that, you should change your theme to remove the extra image sizes.

    It would be helpful to try this out on a sandbox first. See https://wpsandbox.net/
    You could set WP the way it was, upload a few images, then set it the way you want it to be and use the Dynamic Resizer at the same time as Regenerate Thumbnails to see if it deletes and renames like you want.

    Thread Starter webrightnow

    (@webrightnow)

    Thanks for the advice. I wouldn’t know where to start with the command line or with customizing plugins, but it was a good idea to install Regenerate Thumbnails. For one thing, it showed me all the sizes being generated and it turns out the majority of them weren’t being called by the theme, but by a plugin called Co-authors which uses gravatars. For some reason, instead of creating various sizes just for the gravatars, it was doing so for all uploaded images! The developers ought to be shot (metaphorically of course). So I disabled that and removed any unwanted sizes from the theme.
    I am now using Regenerate Thumbnails to go through all images and remove any sizes no longer being used. This should reduce the number of files considerably, so even though they won’t be moved into sub-folders, I may be able to archive the Uploads directory, even if I go 1000 images at a time (there’s going to be about 15,000 after Regenerate Thumbnails has done its work, which will take a few hours).
    I’ll report back!

    You might want to leave a comment on the Co-authors plugin (or a review). Other users could have this problem, and they could fix it for everyone…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Too many files in Uploads folder’ is closed to new replies.