Jump to navigation Jump to search
Other languages: English  • français • italiano • 日本語 • русский
Git logo
Wikimedia Git repository has this file: scripts/

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.
-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
ParameterDescriptionConfig variable
- Read the bot's configuration data from directory given by PATH, instead of from the default directory.
-lang:xx mylang
-family:xyz family
-user:xyz usernames
-log log
-log:xyz logfilename
-maxlag maxlag
Set the minimum time (in seconds) the bot will wait between saving pages. put_throttle
-debug:item Enable the log file and include extensive debugging data for component "item" (for all components if the second form is used). debug_log
-verbose Have the bot provide additional console output that may be useful in debugging. verbose_output
-cosmeticchanges Toggles the cosmetic_changes setting made in or to its inverse and overrules it. All other settings and restrictions are untouched. cosmetic_changes
-simulate simulate
- You may use all given numeric config variables as option and modify it with command line.