0

We have a folder structure of:

assets/user/YYYY/MM/DD/ID/image.jpg|png|...

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:

assets/user/YYYY/MM/DD/ID/tn_image.jpg|png|...
assets/user/YYYY/MM/DD/ID/250x250_image.jpg|png|...
assets/user/YYYY/MM/DD/ID/600x600_image.jpg|png|...
...

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

0

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. – Esa Jokinen Apr 29 '17 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.