Script to resolve double redirects, and to delete broken redirects.

Requires access to MediaWiki's maintenance pages or to a XML dump file. Delete function requires adminship.


python redirect action [-arguments ...]

where action can be one of these:

action description
Fix redirects which point to other redirects. Shortcut action command is "do".
Tries to fix redirect which point to nowhere by using the last moved target of the destination page. If this fails and the -delete option is set, it either deletes the page or marks it for deletion depending on whether the account has admin rights. It will mark the redirect not for deletion if there is no speedy deletion template available. Shortcut action command is "br".
both Both of the above. Retrieves redirect pages from live wiki, not from a special page.

and arguments can be:

argument description
-xml Retrieve information from a local XML dump ( Argument can also be given as "-xml:filename.xml". Cannot be used with -fullscan or -moves.
-fullscan Retrieve redirect pages from live wiki, not from a special page. Cannot be used with -xml.

Use the page move log to find double-redirect candidates. Only works with action "double", does not work with -xml.

NOTE: You may use only one of these options above. If neither of -xml -fullscan -moves is given, info will be loaded from a special page of the live wiki.

-page:title Work on a single page
-namespace:n Namespace to process. Can be given multiple times, for several namespaces. If omitted, only the main (article) namespace is treated. Does not work if retrieving pages from a special page.
-offset:n With -moves, the number of hours ago to start scanning moved pages. With -xml, the number of the redirect to restart with (see progress). Otherwise, ignored.
-start:title The starting page title in each namespace. Page need not exist.
-until:title The possible last page title in each namespace. Page needs not exist.
-total:n The maximum count of redirects to work upon. If omitted, there is no limit.
-delete Prompt the user whether broken redirects should be deleted (or marked for deletion if the account has no admin rights) instead of just skipping them.
-sdtemplate:x Add the speedy deletion template string including brackets. This enables overriding the default template via i18n or to enable speedy deletion for projects other than wikipedias.
-always Don't prompt you for each replacement.

If neither api nor api nor moves are present, information will be loaded using a special page


This syntax fixes all the double redirects. Since no argument is defined, it uses Special:DoubleRedirects of the live wiki to find double redirects by default. It will ask for confirmation before making changes: double

This syntax will attempt to resolve all broken redirects by directing them to the page's most recent move destination. If this fails, then the redirects will be deleted or marked for deletion, depending on whether or not the bot is logged in as a sysop. Confirmation will be asked for before each change: broken -delete

Global arguments available

These options will override the configuration in settings.

Global options
Parameter Description Config variable
-dir:PATH Read the bot's configuration data from directory given by PATH, instead of from the default directory.  
-config:file The user config filename. Default is
-lang:xx Set the language of the wiki you want to work on, overriding the configuration in xx should be the language code. mylang
-family:xyz Set the family of the wiki you want to work on, e.g. wikipedia, wiktionary, wikitravel, ... This will override the configuration in family
-user:xyz Log in as user 'xyz' instead of the default username. usernames
-daemonize:xyz Immediately return control to the terminal and redirect stdout and stderr to file xyz. (only use for bots that require no input from stdin).  
-help Show the help text.  
-log Enable the log file, using the default filename 'script_name-bot.log' Logs will be stored in the logs subdirectory. log
-log:xyz Enable the log file, using 'xyz' as the filename. logfilename
-nolog Disable the log file (if it is enabled by default).  
-maxlag Sets a new maxlag parameter to a number of seconds. Defer bot edits during periods of database server lag. Default is set by maxlag
Set the minimum time (in seconds) the bot will wait between saving pages. put_throttle
Enable the log file and include extensive debugging data for component "item" (for all components if the second form is used). debug_log
Have the bot provide additional console output that may be useful in debugging. verbose_output
Toggles the cosmetic_changes setting made in or to its inverse and overrules it. All other settings and restrictions are untouched. cosmetic_changes
-simulate Disables writing to the server. Useful for testing and debugging of new code (if given, doesn't do any real changes, but only shows what would have been changed). simulate
-<config var>:n You may use all given numeric config variables as option and modify it with command line.