I was working on a project last Fall where a client of mine had a single site collection for their entire document library which was expected to be over 1TB. As a result of the large size of the site collection we decided to break it up into multiple site collections each contained within their own content database (we ended up with 12 in the end). The problem was that when we migrated all the libraries to the new site collections we ended up with hundreds of broken links due to navigation items (as well as web parts and list items) pointing to the original document libraries. The client was prepared to manually go through all the links to correct them but this just seemed a bit crazy to me so I quickly threw together a new command which would recursively go through all the webs and fix any navigation links that were pointing to the old content (I already had something for the web parts and list items). I named this command gl-replacenavigationurls. I actually had this command completed and available since November some time but I completely forgot about it so it never got documented – oops :). I wonder if there’s any other commands that I’ve created but didn’t document? Hmm…
The complete code is shown below (note that at present I’m only supporting MOSS for this one as I’ve not had time to do any WSS rework for it):
The help for the command is shown below:
C:\>stsadm -help gl-replacenavigationurls stsadm -o gl-replacenavigationurls Replaces URL values in the current and global navigation matching the provided search pattern. Parameters: -url <url to search> -searchstring <regular expression string to search for> -replacestring <replacement string> [-quiet] [-scope <WebApplication | Site | Web> (defaults to Site)]
The following table summarizes the command and its various parameters:
|Command Name||Availability||Build Date|
|gl-replacenavigationurls||MOSS 2007||Released: 1/18/2009
|Parameter Name||Short Form||Required||Description||Example Usage|
|url||Yes||URL of the web application or site collection.||-url "http://portal"|
|searchstring||search||Yes||The regular expression search string.||-searchstring "(?i:/doccenter/IT)"
|replacestring||replace||Yes||The replace string.||-replacestring "/docs/IT"
|quiet||q||No||Specify to suppress status information while the command is running.||-quiet
|scope||s||No – defaults to site||The scope to use. Valid values are “WebApplication”, “Site”, and “Web”.||-scope site
The following is an example of how to replace all references to “/doccenter/IT” with “/docs/IT”:
stsadm -o gl-replacenavigationurls –url "http://portal" –searchstring "(?i:/doccenter/IT)" –replacestring "/docs/IT" –scope WebApplication