Drupal bulk delete nodes per filter


<?php
error_reporting(E_ALL);
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$nodetype = "nodetype";
$uid = 1468;
$limit = 500;
$results = db_query("SELECT nid FROM {node} WHERE type='%s' AND uid=%d LIMIT %d", $nodetype, $uid, $limit);

$count = 0;

while ($result = db_fetch_object($results)) {
node_delete($result->nid);
print 'Deleted node: ' . $result->nid . '';
$count++;
}

print "Total deleted: $count";

?>

May 29, 2018