We have a folder structure of:


and there are over 8,000+ users posted on on different times and different IDs.

Within that same folder we create 6 different sizes of thumbnails such as:


How can I delete all of these resized versions and on?

1 Answer 1


I assume the original images are the oldest images. You could go for a script that deletes every file that is newer than... So if your original image is more than 31 days old, use:

find assets/user/\*/\*/\*/\*/ -mtime -31 -type f -exec rm -rf {} \;

BE CAREFUL! This line will search in all folders, so all the original images have to be the exact same aged. If they are not, then use specific folders for each. Like:

find assets/user/YYYY/MM/DD/ -mtime -31 -type f -exec rm -rf {} \;
  • This answer isn't useful at all, because the images are "posted on different times and different IDs". The pattern of filenames is most likely the key here, not the last modified time. You'll need the magic of regular expressions. Commented Apr 29, 2017 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .