Use drush to bulk-update pathauto aliases

by jenny on 07 August 2012 - 07:08pm in

After changing the pathauto pattern for a node of type foobar, each node must have pathauto_node_operations_update() run on it. If you have a lot of nodes to update, using the drupal shell (drush) is the easiest way to go.

Test run: Just print node ids to be modified

sudo drush eval '$resource = db_query("select nid from node where type=\"foobar\"");
while($result = db_fetch_object($resource)) $nodes[] = $result->nid;
print_r($nodes);'

Pull the trigger: Update the nodes

sudo drush eval '$resource = db_query("select nid from node where type=\"foobar\"");
while($result = db_fetch_object($resource)) $nodes[] = $result->nid;
pathauto_node_operations_update($nodes);'