My media has over 100k images. I filtered it out by name and deleted it but limited to 200 pictures, if more would get the error "URI Too Long error". So can you show me how to batch delete photos by name in Media? I have used plugins like Media Cleaner, WPS cleaner but it doesn’t work, it takes a lot of time. I use WordPress Bitnami on Google cloud.
Thanks for the help.
2
Answers
You can achieve it by using below script.
Please make sure before running this script take a database & full site backup.
Script
How to use it
You can create a custom template and put the above code. Then create a page using newly created template then visit the URL. It will display the list of media that is deleted. You can also setup a CRON which will do the stuff in the background.
The code is tested, and fully functional.
If you have SSH access to your VM instance running WordPress then you can connect to it,
cd
into/bitnami/wordpress/wp-content/
(this is where the files are located when you use Bitnami solution) and delete files manually by runningrm
command.rm *common_file_name_part*
If for some reason files are not where they should you can locate them with
find / -xdev 2>/dev/null -name "wp-content"
.Here you can find some practical examples how to use
find
.Before deleting anything I’d recommend doing a copy of the directory you’re in. Or even creating a snapshot of the entire VM’s disk.