LuckyRename
DescriptionMakes requesting file moves easier and automates the many steps in file moving, including automatic replacement of existing usage.
Author(s)User:Alexis Jazz
UpdatedMay 9, 2023; 18 months ago (2023-05-09)
SkinsVector, Minerva, Modern, Monobook, Timeless
SourceUser:Alexis Jazz/LuckyRename.js

LuckyRename is a user script to ease requesting file moves and for file movers to streamline moving files, including automatic replacement of existing usage. With LuckyRename, even a complete idiot can move files properly. You don't even have to ponder appropriate filenames anymore: just press the Feelin' lucky button and see what happens!

The four-leaf clover is Unicode U 1F340. See the history of the test version for a changelog of sorts.

How to install

edit

Add this to m:Special:MyPage/global.js to load the script globally:

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Alexis_Jazz/LuckyRename.js&action=raw&ctype=text/javascript');

To load the script on a specific Wikimedia project, add the line to Special:MyPage/common.js on the project in question instead.

How to use

edit
 
LuckyRename after the Feelin' lucky button generated an appropriate filename

After installation you will get an additional tool link (somewhere near Twinkle if you have enabled that as well) and a little four-leaf clover next to the file info on file pages, for example: "(250 × 375 pixels, file size: 110 KB, MIME type: image/png) 🍀". Click either the tool link or the four-leaf cover and LuckyRename will open. There is no tool link on the mobile site, only the four-leaf cover is available there.

Request a move or move a file

edit
  1. Enter the desired target filename or press Feelin' lucky and adjust as needed.
  2. (optional) Select a reason for moving the file from the drop down menu and/or enter a custom reason.
  3. Press either Request move to request the move or (file movers only) Move file to actually move the file and replace existing usage.

When using Feelin' lucky, if the file is used on more than one article you can press Feelin' lucky again to cycle through the filename suggestions for each article. If the background of the filename field is green, the entered name is valid. If it's red, it isn't and the reason will be visible within the field on the right side. If it's yellow it's identical to the current name.

Decline a move request

edit
  1. (optional) Enter a reason for declining the move request.
  2. Press "Decline".

If you're not a file mover you'll have to press "Override" first. If you're not a file mover, please only decline clearly bogus requests and vandalism.

Illegal characters

edit

The following characters will be flagged as illegal by LuckyRename:

  • :, /, \, #, [, ], {, }, <, >, | and non-ascii characters /[\\x00-\\x1f\\x7f]/ are disallowed by MediaWiki. LuckyRename tests for /[^\x00-\xFF]/ instead of /[\\x00-\\x1f\\x7f]/.
  • /, ?, <, >, \, :, *, | " are disallowed in Windows filenames (?, * and " are allowed by MediaWiki)
  • ^ is disallowed in filenames when using FAT
  • . as the first character indicates a hidden file on various operating systems (but not on Windows), periods are allowed when they are not the first character
  • ! has special meaning in C shell which might cause problems for someone who downloads the files and tries to process them with a script. It's rarely appropriate anyway.

If LuckyRename flags the filename that is entered as unacceptable you can use the "Override" button to request/move the file anyway. You will be appropriately warned.

Override

edit

The "Override" button disables various sanity checks and relabels the "Move file" button to "YOLO!". It will also unlock the "Decline" button if you're not a file mover. Override at your own risk. Acceptable uses of override:

  • A sanity check in LuckyRename is bugged. Please report the bug so it can be fixed.
  • You absolutely must use ?, *, ", ^, ! in the filename or have a . as the first character and your hands are tied. Please try to find an alternative if you can.
  • You are not a file mover but have identified a rename request as clearly bogus/vandalism and want to decline it.
  • Generate a Feelin' lucky suggestion from an article the file isn't used on. (you can enter the article title to use when you override)
  • You need to resolve redirects for a manually moved file, updating articles and other pages to link to the current name instead of the redirect. To do this: press override, then press "Resolve redirects". The edit summary will be adjusted accordingly.

Features

edit

Everyone

edit
  • Integrated list of WP:FNC criteria. Never copy-paste again!
  • Automatically checks if the chosen filename is in use either locally or on Commons
  • Automatically checks if the chosen filename contains illegal characters
  • Doesn't change watchlist settings for any edited page
  • Feelin' lucky: too drunk to come up with a better filename? Just hit the button!

File movers

edit
  • Automatically replaces existing usage (including file links, links to the associated talk page and updating redirects)
  • Automatically removes {{Rename media}} and {{ShadowsCommons}} from the file page
  • Automatically unchecks leaving a redirect when selecting WP:FNC#9 (shadows a Commons file or redirect)
  • Automatically tag the redirect for speedy deletion if you don't have the suppressredirect right which is only available to page movers and admins. Tags {{Db-r4}} if it shadows Commons, {{Db-g6}} with reference to WP:PMRC#10 otherwise provided the file is linked from less than 20 pages.
  • Fully {{Bots}} compliant for usage replacement (can be useful for lists of files in user space), will not edit pages where "luckyrename" or "userscript" is denied
  • {{Automatically generated}} compliant, no links or usage on automatically generated pages with that template will be replaced.
  • Automatic workaround for phab:T235589

Feelin' lucky

edit

Examples

edit

Sometimes the generated filename isn't ideal though:

  • File:Nikolay Prishchepa.jpg.pngFile:Nikolay Prishchepa (military personnel, born 1900).png, better to say "major general" instead of "military personnel".
  • File:Prince logo.svgFile:Prince (film actor, singer, film director, singer-songwriter, screenwriter, record producer, film score composer, film producer, multi-instrumentalist, musician, dancer, guitarist, composer, actor, acting, born 1958) logo.svg, it's not wrong really.

How Feelin' lucky works

edit
  • Checks the title of the first article in mainspace the file is used on. If the image isn't in use in mainspace, Feelin' lucky won't work. If the first article it's used on is only loosely related to the file (e.g. a list article) the suggestion will be useless. You can activate the lucky button again to try the next article the image is used on.
  • Obtains various statements from the associated Wikidata item for the article
  • Checks the file page for certain templates (logo, screenshot, etc)
  • ?
  • Profit!

Troubleshooting

edit
Issue Solution
LuckyRename seems to be stuck with the progress bar nearly full. It's probably not stuck but just replacing the file name in a huge (typically bot-generated) list like User:Kotepho/reports/orphaned fairuse media5. This may take several minutes. Check "What links here" to ensure all usages have been replaced. If the list is unmaintained and not actively used for anything, you can add {{Automatically generated}} or {{bots|deny=luckyrename}} to that list so LuckyRename won't try to edit that page again, significantly speeding up the process.
"Feelin' lucky" is grayed out. File is not used in article space. If you know what the file depicts you can use the "override" button and enter the article title for Feelin' lucky to use.
My computer or internet broke in the middle of a file move. The actual move always comes first.
  • If you find no trace of the move in Special:MyContributions, nothing happened.
  • If the move succeeded but related edits failed and you left a redirect while moving: go to the file page, press "Override" and press "Resolve redirects" to complete the move.
  • If you didn't leave a redirect: create a redirect from the previous file name to the current name, go to the file page, press "Override" and press "Resolve redirects" to complete the move.
A {{Rename media}} request that spans multiple lines isn't processed correctly or not at all. Keep your {{Rename media}} on a single line. There's no easy fix for this.
I get JavaScript errors. Please report them.
Someone using LuckyRename is editing a page I don't want them to edit. Add (if applicable) {{Automatically generated}} or {{bots|deny=luckyrename}} to the page in question.

Known issues and missing features

edit

See this subpage for resolved issues.