Answer the question
In order to leave comments, you need to log in
What is the best way to implement deleting user photos?
Friends, please advise in this situation.
There are a lot of folders for user photos
i/41/thumbs/...
i/41/original_photo.jpg
i/41/original_photo2.jpg
i/41/original_photo3.jpg
---------
i/53/ thumbs/...
i/53/original_photo.jpg
i/53/original_photo2.jpg
i/53/original_photo3.jpg
41, 53 is the user ID, which can be taken from the database if necessary.
The essence of the problem:
I need to delete all the original photos of all users, but at the same time I can not touch the thumbs directory.
I thought at first to implement it in php through and run the console command, but now I'm leaning towards python or bash.
Please tell me how you would act in this situation, and if it does not make it difficult, then an example.
Thank you.
Answer the question
In order to leave comments, you need to log in
find . -type f -name 'i/*/*.jpg' -exec rm {} +
or like this
find . -type f -name 'i/*/*.jpg' -and -not -path '*thumbs*' -exec rm {} +
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question