Bulk Update All Objects
Older versions of Pathauto (4.7 and 5.x-1) regenerate all aliases of the requested type during a bulk update when the Update action (at Administer > Site Configuration > Pathauto > under General Settings) is set "Create a new alias, replacing the old one."
Bulk update replaces all old aliases with new ones. However, this bulk update created problems, such as incomplete updates and/or server time-outs, for very large sites and/or on particularly slow servers.
Bulk Generate For Non-Aliased Objects Only
As of Pathauto 5.x-2.x or Pathauto 6.x-1.1, bulk update only generates aliases for non-aliased objects - if a node already has an alias, it will not be updated during the bulk update. You might run into problems if you add feed aliases or tracker aliases to an already aliased object. It is best to delete the object's alias and bulk update them.
Deleting all aliases
To regenerate all aliases from a clean slate, Pathauto 5.x-2.x and Pathauto 6.x-1.1 provides a "Delete all aliases" option. You can selectively delete by "all aliases", "users", "content", "user blogs", "vocabularies and terms", and "user trackers".
In Pathauto 5.x-2.x the "Delete all aliases" options can be found at: Administer > Site Building > URL Aliases > under the "Delete all aliases" tab (admin/build/path/delete_all).
In Pathauto 6.x-1.1 the "Delete all aliases" options can be found at: Administer > Site Building > URL Aliases > under the "Delete all aliases" tab (admin/build/path/delete_bulk).
Warning: This will permanently delete aliases from your site. You will not be asked again "are you sure you want to delete all aliases?"
Updating aliases of a certain node type
There is no option within Pathauto for updating only a particular node type, while leaving other nodes untouched. But there is a simple procedure for doing this if you don't have too many nodes you need updating. Works for both Pathauto 5.x-2.x and Pathauto 6.x-1.1.
- Set what you would like done with existing aliases in Pathauto "General Settings":
- Do nothing. Leave the old alias intact.
- Create a new alias. Leave the existing alias functioning.
- Create a new alias. Delete the old alias.
- Create a new alias. Redirect from old alias. (depends on Path Redirect)
- Go to "admin/content/node"
- Filter by content type
- Select all nodes
- Select "Update path alias" from drop down
- Repeat for number of pages you have of that content type
You can also selectively delete aliases by running advanced queries against your database. For example, the following query will delete all node objects:
DELETE FROM url_alias WHERE src LIKE 'node/%';
OR
DELETE FROM url_alias WHERE dst LIKE 'my_custom_pattern/%';
If you need to delete the aliases of a range of nodes by nid you could use the code:
// delete url aliases between nid 22060 and 22433
$nid = 22060;
while ($nid < 22434) {
db_query("DELETE FROM {url_alias} WHERE src LIKE 'node/%d'", $nid);
$nid++;
}
Performing bulk updates in configurable chunks
For sites that need to generate large numbers of aliases or sites that run on slow servers, Pathauto 5.x-2 offers the option to perform bulk updates in configurable chunks - you can specify the number of objects to alias in each bulk update.
Note: if you set the limit to 50 objects per bulk update and have feed aliases enabled, then
100 new aliases should be generated per bulk update (2 aliases per object).
Note: If you are concerned about the effect of bulk update on your site, you should
backup your database (particularly the url_alias table) prior to executing the Bulk update.
Comments
Bulk update for PathAuto Drupal 6
Just to clarify the process to bulk update your aliases in PathAuto Dr6, based on my recent experience:
Selectively updating certain patterns
We wanted to change all /films/example style paths to /film/example (basically remove the 's').
Here was the query that worked:
Thank you Jason
-zach
: z
This pattern was very helpful
We had issues with our path for user profiles conflicting with our path for users (since we had both set to be user/----). We used the following query to update the user profile paths:
UPDATE url_alias set dst = replace(dst, 'user/', 'profile/') WHERE dst LIKE 'user/%' and src LIKE 'node/%';
(The AND condition was necessary to prevent the paths for users from getting overwritten, also.)
Nonprofit / EdTech Mentor
http://drupal.org/user/168664
In above tutorial, you talked
In above tutorial, you talked about deleting alias for range of node using the php code. But when I created a file named 'aliasdel.php' with the above mentioned code and tried to run it, a message was generating saying 'Fatal error: Call to undefined function db_query() in /home/test/public_html/aliasdel.php on line 5'
I believe this is the wrong way of running this code. Please tell me what is the right was of running this code so that aliases for certain set of nodes could be deleted.
You'll need a bit more code...
If you're being told that db_query() is an undefined function, then my guess is that you literally ran only the above code. (The code sample above presumes it's being tied into the Drupal core in an earlier section of the page.)
Basically, you'll need to run the code on a page that's hooked into Drupal's core includes -- because they're what give you access to Drupal's database-altering functions. There are different ways to do this, but in your case you can try simply adding the following lines to your test .php file (immediately after the ?php tag opening):
(PS: I know it's been about two months and you've probably already figured this out, but I couldn't let the unanswered question just sit there.) ;-)