Community & Support

Mass Delete Old Content [nodes]?

Background: I was using aggregator2 to run a site [http://technology4teachers.com] that aggregated numerous RSS feeds and promoted them to nodes. I upgraded to 4.7.3 and this isnt working anymore. That's no big deal and not the issue except that I am now the proud owner of a website that has about 595 pages with 30 stories each that I would like to remove.

Issue: How does one easily remove over 17500 stories? Searching the documents here for "remove old content", "delete old content", "delete old nodes" did not yield useful information.

Comments

=-=

would probably be easiest by removing them out of the database itself. using phpmyadmin or whatever your host allows to access your DB.

Try this

UPDATE {node} SET STATUS=0 where nid > whatever

Change the the where clause to target the nodes you want. Also you'll need to change the {node} to whatever you node table is named.

Drupal 7 . . . the most commercial Drupal yet!
Drupal 7 . . . 1 2 3 3+ years in the making!

SOLVED

I solved this issue by executing some SQL against the drupal database. I used the commands:
DELETE FROM node WHERE type='aggregator2-item';
and
DELETE FROM node WHERE type='aggregator2-feed';

I hope this helps others.
technology4teachers.com

not quite good

This will leave you with a lot of garbage on your database... like orphan term_node references...

--
"Slackware users: Klingons of the computing world."
http://blogs.nshp.org/dsouza

--
"Slackware users: Klingons of the computing world."
http://blogs.nshp.org/dsouza

any way of doing this now?

any way of doing this now?

=-=

you can filter the content at administer -> content
use the checkall check box and batch delete.

automatically? cron?

Hi, I was wondering if there was a way to do this automatically... I'd love to set a script to delete any nodes of a certain type and a certain age that have not been published... daily.

cheers,
scot

web2scale.com (business)

scottpolley.com (professional)

scothiam.com (enthusiast)

Look at the Auto Expire module

See http://drupal.org/project/auto_expire

Allows for unpublishing and purging.

Think Outside the Box

First, get the Devel module if you don't already have it: http://drupal.org/project/devel
Activate Devel generate for generating dummy nodes. I know what you're thinking: "I want to get rid of my nodes, not generate more dummy nodes." But here's the beauty: Devel generate gives you the option to wipe out all nodes of a particular content type before generating new ones.
Go to Administer > Generate items > Generate content
Select the content type you want to get rid of.
Put a check in the "Delete all content in these node types before generating new content" checkbox.
Under "How many nodes would you like to generate?" put 1. I tried putting in 0, but then Devel didn't do anything.
Click the "Do it!" button.
Go delete the one node that Devel generated.

Worked like a charm. I'm really pleased with myself for having thought of it. :)

Now, if you don't want to delete ALL the nodes but just some with a particular publishing date, that's trickier. Maybe export the ones you want to keep, delete everything, and reimport them.

Why think outside the box, if

Why think outside the box, if there is within the box a solution: http://drupal.org/project/delete_all
greetings, Martijn

Not in a recommended release

Not in a recommended release for Drupal 6 though.

Thank you thank you thank you

I just logged on to say thank you... I accidently overlooked a field when uploading about 4000 nodes.. and needed to delete and reupload. Thanks for saving me half a day of manually deleting them!

I like my idea of archive and

I like my idea of archive and remove like Gmai's archive feature only move it to a separate database for storage and you can still display it if you wanted to. This gets all that old content out of the main database.

You could always use the cmf

You could always use the cmf module. It's similar to the listing in admin/content/node but gives extra options, one of them being the number of rows to show in the page.

node_delete_multiple(array($nid));

Do a SQL query to get an array of $nids, then call node_delete_multiple with that array.

my Drupal book | Twitter | Senior Drupal Advisor, Acquia | Advisor ICanLocalize

Looks something like

Looks something like this:

<?php
  $result
= db_query("SELECT nid FROM {node} WHERE type=:type;", array('type' => 'your_type'));
 
$nids = array();
  foreach (
$result as $row) {
   
$nids[] = $row->nid;
  }
 
node_delete_multiple($nids);
?>

my Drupal book | Twitter | Senior Drupal Advisor, Acquia | Advisor ICanLocalize

nobody click here