Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mass delete content and file nodes with filters

What is a good drupal-friendly way to mass delete thousands of nodes and files with selective filters? I need this functionality to supplement my drush mass import script.

like image 474
bdombro Avatar asked Dec 06 '13 17:12

bdombro


1 Answers

I couldn't find any solutions in the community with searching, so I solved the problem myself. Here is what I came up with:

Solution 1: Works on content AND file nodes, AND supports complex select filters. Plus has nice front-end interface with progress bar

Prereqs: Views, VBO (Views Bulk Operations)

Instructions: Create a table of fields view with whatever filters you want, and add a VBO field with option to delete. I recommend using a paged view. When you visit the page, click the select all button for VBO in the top of the table. Now you should be able to see a new option right under the header of the table, which says "Select all in this view". Click that button, which selects ALL matches to the view filter. Finally click the delete all option in VBO, and VBO deletes ALL nodes in the view.

Awesome sauce!

Solution 2: Works on content, but NOT on files. Also does not support complex select filters. Also, no progress bar.

Prereqs: Drush

Instructions:

drush genc --types=<content type machine name> --kill 0 0

Solution 3: Works on content, but NOT on files. Also does not support complex select filters. Also, no progress bar.

Prereqs: Drush, delete_all plugin

Instructions:

drush delete-all <content type machine name>
like image 60
bdombro Avatar answered Oct 18 '22 22:10

bdombro