Here is a module that can come in handy in certain cases.
Say you have a site and want to delete all content in it.
- This is a test site that the client was using for a period of time, and they must clean it up before starting with real data.
- You are testing something that creates a lot of nodes (e.g. aggregator), and want to do it over and over again.
- You created a site in the past and want to replicate it again, but with new content.
The traditional way of doing this is to go into administer -> content then select all the nodes and delete them. This works if you have a handful of nodes only. If you have hundreds or thousands of nodes, then it is not a practical solution.
Another option is to directly delete the nodes from the node table in the database. This does not work properly, since there are also comments, and many tables for add on modules that needs to be cleaned.
So, my solution was to write this small module to delete all content programmatically.
I am attaching two files, one for 4.6 and the other for 4.7.
Download the module for your Drupal version below, copy them to your modules directory, enable the module, then visit http://example.com/admin/node/deleteall
The module is now updated for Drupal 5.x, and lives in the Drupal repository. It also provides an option to delete all users. See the Delete all project.