This is the talk page for discussing improvements to the CategoryRenameAuto-update page.


I noticed that this script adds the "Rename" button to every drop-down menu with the 'wikia-menu-button' class, including the Contribute menu. My suggestion would be to change
$('.wikia-menu-button .WikiaMenuElement').append(...
$('#WikiaPageHeader > .wikia-menu-button .WikiaMenuElement').append(...
so that it only targets the Edit menu.

RyaNayR (talkcontribs) 08:09, February 21, 2014 (UTC)

REALLY late, but thank you! — Foodbandlt (talk) 06:39, December 22, 2014 (UTC)

Removal/Delete functionality?

What would be nice is if there was a way to *not* give a new name. Perhaps by leaving the New Category field blank, or however it can be coded, it would then *remove* the Old Category entry from pages, replacing it with nothing, and in effect simply removing Outdated/Unnecessary Cats. Combined with the "Delete old Cat" function, and it we'd have it all. --Love Robin (talk) 13:41, April 4, 2014 (UTC)

I love this suggestion! :) — SpikeToronto 13:53, December 22, 2014 (UTC)
MassCategorization has the mode to remove categories. – Ozuzanna 14:04, December 22, 2014 (UTC)
Going to agree with Oz. I hate to say import two scripts, but this is a very specific script and others have already invented the wheel for what you described. — Foodbandlt (talk) 15:00, December 22, 2014 (UTC)
Hmmm … one more script to load … *groan* … my poor little iPad is going to up and die under the strain … :'( — SpikeToronto 15:17, December 22, 2014 (UTC)
UPDATE: Well, I’ve given it a try and, unless I’m doing it incorrectly, MassCategorization for removing categories is not quite what Love Robin and I had in mind. In my attempt, I wanted to de-categorize all pages in a particular category. Then, when the category is resultantly empty, I would just delete the category page; or, better yet, the script would. However, the script requires that, in addition to selecting remove and inputting the category name to be removed, I have to input a list of every page populating that category. Why? The system already knows every page that populates that category. I understand that a blank line is the script’s clue that it has reached the end of the list and to stop running. So, something would need to be input into the list box, that we cannot just leave it empty. To that end, could we device some special “codeword” that we input instead of a list, a codeword that signals to the script that it is to perform the de-categorization on all the pages in the category? Thanks! — SpikeToronto 15:23, December 23, 2014 (UTC)
Have you tried using the "Add category contents" button? Also I don't want it to auto remove categories after giving the category name for all of them, as the user may only want to remove a select few. – Ozuzanna 16:06, December 23, 2014 (UTC)
If the user only wanted to remove a select few, he’d list them. ;) Plus, that’s why I suggested some unique tag that, when placed in the list box, tells the script to act on all pages in the category. Thanks! :) — SpikeToronto 22:09, December 23, 2014 (UTC)
P.S. I haven’t tried the “Add category contents” button. I’ll do that now. I’m sure that’ll do the trick! Thanks! :) — SpikeToronto 22:09, December 23, 2014 (UTC)
That's a good idea, and I'll keep it in mind. – Ozuzanna 22:41, December 23, 2014 (UTC)

──────────────────────────────────────────────────────────────────────────────────────────────────── First, mea culpa: I didn’t really understand how the interface was supposed to work. It wasn’t very intuitive. However, since you explained the function of the “Add category contents” button, it’s become a lot clearer to me how this script is supposed to work and to be utilized by us. In short, Ozzie, it is awesome!! I have had a long-as-my-arm list of category namespace clean-ups since the dinosaurs roamed the earth. But, I prefer working on my iPad to using my laptop. So, I’d kept putting off, and putting off, using AWB to do those tasks. Well, the MassCategorization script lets me do them all with my little iPad. Thanks!! :) — SpikeToronto 11:55, December 28, 2014 (UTC)
P.S. I would suggest devising a small chart/table that distinguishes MassCategorization from CategoryRenameAuto-update. When to use which script is not immediately obvious or easily understood. Thanks! :) — SpikeToronto 11:55, December 28, 2014 (UTC)

P.P.S. Now that I understand the “Add category contents” button, it makes my tag/codeword suggestion earlier moot. Just toss that one in the bin! :$ — SpikeToronto 11:57, December 28, 2014 (UTC)

Occasional error message

Every so often I get the error message: The page "PAGENAME" could not be created due to error code: "emptypage"

Any idea what this is?

The last one I got this was for w:c:braceface:Category:Villians which I want to rename to "Antagonists", and is misspelled anyway. --Love Robin (talk) 06:30, August 13, 2014 (UTC)

Again, really late, but I've fixed it. If a category page is empty it now adds a period as I don't know how to actually make an empty page (and it's not obvious). — Foodbandlt (talk) 06:40, December 22, 2014 (UTC)

Page Rename

will there be equivalent for page renames? ie change all links on "what links here" Reasno 杰诺斯·史林特 04:03, August 26, 2014 (UTC)

I'll make it conditionally update links as well at some point. I didn't get to it tonight.Foodbandlt (talk) 06:41, December 22, 2014 (UTC)
I think I misunderstood you, actually. PageRenameAuto-update might be what you're looking for. — Foodbandlt (talk) 19:28, December 22, 2014 (UTC)

User group restrictons

Would it be possible to restrict this script to sysops-only? Perhaps as a variable preceding the import statement in Common.js. Thanks! :) — SpikeToronto 05:56, November 18, 2014 (UTC)

I would disagree with that notion on the Dev Wiki script because I know some wikis who use the script and are not sysop. I would suggest adding that yourself to your own version of the script somewhere. – Ozuzanna 19:06, November 18, 2014 (UTC)
One would have to know JS to do that… :( Would it be possible to alter the dev script so that, just above the import over at another wiki, there could be some parameter setting/value that limits the user groups for which the script operates? It could default to autoconfirmed if no parameter is supplied at the importing wiki. Thanks! — SpikeToronto 02:58, November 26, 2014 (UTC)
Instead of altering the script, you could add a conditional in your import, like so:
if (mw.config.get('wgUserGroups').indexOf('sysop') > -1) {
    importScriptPage('CategoryRenameAuto-update/code.js', 'dev');
-- sqm talk 14:03, 11.26.2014
[edit]→ Or, add the import to mediaWiki:group-sysop.js. -- sqm talk 14:07, 11.26.2014
That’s perfect! I’ll give that a try. Thanks! :) — SpikeToronto 08:08, December 2, 2014 (UTC)
It just occurred to me, though, that that will not prevent someone from adding CategoryRenameAuto-update to their personal JS and running it. Will it? — SpikeToronto 08:18, December 2, 2014 (UTC)
No, it won't. There are ways to prevent it on a per wiki basis, but there are way to get around it just with minimal js knowledge.
For example, the author of this could add a check for a global config that disables the import for non-sysops. But the user could just unset that config before importing it. Another option would be to add the restriction to the code, but then I could just copy the code to another location and remove that restriction.
Perhaps a lot of users lack the knowledge to do wither of those examples, but if I can think of ways around it I'm sure someone else can. cqm 11:17, 3 Dec 2014 (UTC)
Anyone whose javascript knowledge is at that level is not someone one has to worry about messing things up inadvertently. ;) — SpikeToronto 06:35, December 15, 2014 (UTC)

──────────────────────────────────────────────────────────────────────────────────────────────────── Some people may use scripts in order to vandalize. Undoing the renaming of a bunch of category pages can be hard, especially if the person or people undoing do not use a bot or a script.[Template fetch failed for] 15:25, July 13, 2016 (UTC)

Error code

I tested the CategoryRenameAuto-update script on Test 12 Wiki and received the following error message for some, but not all, of the pages that were re-categorised:

The page at says:

The page "<page name>" could not be submitted because of error code:"internal_api_error_DBQueryError". Please update the link(s) on that page manually.

Could someone please explain why these errors occurred and if they're significant? --LegendFPS (Talk) (Contribs) 06:28, December 2, 2014 (UTC)

That's likely a error in wikia's config or code, it's not a standard api error code afaik. I'd suggest trying again in a couple of days to see if it's fixed. cqm 10:28, 2 Dec 2014 (UTC)
Ok, I'll do that. Thanks. --LegendFPS (Talk) (Contribs) 06:46, December 3, 2014 (UTC)
It worked fine on the second attempt. --LêgêndFPŠ (Talk) (Edits) 03:06, December 9, 2014 (UTC)

Non-English languages

The script doesn't seem to work on non-English wikias. Could someone please try and fix this ? Thank you in advance. —Hulothe @fandom 16:26, December 21, 2014 (UTC)

I'll try to get this done today. I might need help with translation for some things though if you're willing to help. — Foodbandlt (talk) 19:01, December 21, 2014 (UTC)
Thank you. I'm willing to help with translations. —Hulothe @fandom 21:51, December 21, 2014 (UTC)
Multilingual support update is now up, it just needs translations. Sorry this took so long. There was a lot more text than I originally thought there was. — Foodbandlt (talk) 06:42, December 22, 2014 (UTC)
I added fr, it works great ! Thank you very much. I will add some other languages if I'm able to. —Hulothe @fandom 10:26, December 22, 2014 (UTC)
I thought that, in order to not have the script become too long, we make separate versions per language, like
  • CategoryRenameAuto-update/code.js
  • CategoryRenameAuto-update/fr/code.js
  • CategoryRenameAuto-update/pl/code.js
  • CategoryRenameAuto-update/de/code.js
  • etc.
Or, does that not apply in this case. (confused) :) — SpikeToronto 15:22, December 22, 2014 (UTC)
I actually don't know, this is the first script that I've ever included multiple language support on. A couple that I looked at didn't split it up but mentioned it. I'll look around, thanks Spike! — Foodbandlt (talk) 15:33, December 22, 2014 (UTC)
You’re welcome! :) — SpikeToronto 15:57, December 22, 2014 (UTC)

────────────────────────────────────────────────────────────────────────────────────────────────────All right, the languages have been split to separate pages and only the one that's needed is loaded. You might find it to take about a half-second longer to load as a result. — Foodbandlt (talk) 18:42, December 24, 2014 (UTC)

That’s brilliant Foodie. Thanks! :) — SpikeToronto 11:44, December 28, 2014 (UTC)
It seems like for any language that doesn't have a translation ready, it hangs while trying to load the file since it doesn't exist. Could it be made to default to English in such cases?Robo Kiss (talk) 21:11, April 19, 2015 (UTC)
I see bits of code like
if (typeof CRA.supportedLanguages.indexOf(mediaWiki.config.get('wgUserLanguage')) == -1){
					var userLang = "en";

where it seems like what I said is the intended behavior, but I guess something is off. Should this line

url: "" + mediaWiki.config.get('wgContentLanguage') + ".js?action=raw&ctype=text/javascript",

instead be using userLang in the middle?Robo Kiss (talk) 22:13, April 19, 2015 (UTC)

The content language pack being available is a prerequisite to loading the user language pack (if different) because it needs the translation of the Category namespace name. In hindsight I've found a way to get that without a language pack since then. I'll look into changing that. — Foodbandlt (talk) 12:59, April 20, 2015 (UTC)

(Adding a tricky issue) Um... is it possible to make non-English wikis load the English version if their languages isn't currently available? I was originally thinking to translate that to Chinese as it is recommended, but the character variations as well as phrase usage differences hold me back. :( TsukiYaksha月夜叉 Forest Spirit of the Moon 07:12, July 12, 2015 (UTC)

Yes it is possible, though I need to make some changes to the script. When I first wrote it I wasn't aware that Mediawiki offered translated namespace names in a variable, so I required the native language translation for a wiki. So I need to make a few changes, though I don't really have time to do it at the moment. I'll try to get to this. — Foodbandlt (talk) 12:49, July 16, 2015 (UTC)

Why piping?!

Why is it “piping” the categories it changes on the changed categories’ constituent pages? For example, see

This raises serious issues:

  1. The righthand-side of the pipe in a category is used to specify sort order.

    • Thus, the “Cindy Lou Who” page (see example) categorized as

[[Category:Characters with antlers|Characters with a antlers]]

means that on the “Characters with antlers” page, it files not by “cindy …”, but by “characters …”

    • “cindy” and “characters” are alphabetically close, but suppose that the page being categorized thusly were instead called “Thomas the Tank Engine”

      • the page would slot in under the C’s — as in “characters” — instead or under the T’s — as in “Thomas”.
    • It’s really up to each wiki’s categorization policy to determine the sort order of its articles.
  1. It is counterintuitive to use a pipe to continue to show the category on the page as it was — in this case, the incorrect "characters with a antlers” — especially since “as it was” was wrong and renamed for that reason. ← (It doesn't really do this anyway: it's all about sort order right of the pipe. :P)
  2. Compounding this issue, editors at our wiki have begin copying the method — unnecessarily piping categories — yet having zero understanding of the consequences of piping them. Moreover, the two sides of the pipe often bear no resemblance to each other, or any relation to the page on which it is placed! For example,
    [[Category:Horror films|Turtle McGurtle]]
    on a page about Friday the 13th! You can imagine the chaos this is creating.

Thanks. — SpikeToronto 13:06, December 22, 2014 (UTC)

Ahh, you're right. I hadn't considered it because MLP Wiki doesn't generally ever use pipes in categories other than when Wikia bugs pop up. Would you suggest that I remove the pipe and text after it, then? Or be able to specify what should come after the pipe? — Foodbandlt (talk) 14:00, December 22, 2014 (UTC)
@Foodie: It should just replace the category, no pipe. So, in the example above,
[[Category:Characters with a antlers]]
would just become
[[Category:Characters with antlers]]
without the extra a. This is essentially how one would do it if one were doing it manually. (By the way, on one wiki, we use sort order a lot, most often in the form
to ensure that the category pages list the entries correctly. Anyway, thanks for fixing this! :) — SpikeToronto 15:14, December 22, 2014 (UTC)

──────────────────────────────────────────────────────────────────────────────────────────────────── It’s official ==> I’m an idiot. :$ — SpikeToronto 15:53, December 22, 2014 (UTC)

Links to category on page

(See EDIT 2 too)
I found something thats prevents the script from working as it should: if a link to the category being renamed is already present on the page, then the script will only change this one instead of the actual category. An example here. What it should have done corresponds to the next change that I've made manually. Could you please try and find a solution to this problem? Thank you again for your great work. —Hulothe @fandom 22:58, December 22, 2014 (UTC)

EDIT : if, by the way, it could replace (optionally, by checking a checkbox) all the links to this category on any page just like does FileUsageAuto-update for images, it'd be great, too :-)

EDIT 2 : It seems that the error mentionned above doesn't affect only links to the category, but every single word that is the same as the category name (not incuding Category:). You can see an example here.

Hah, that's odd. It looks like when I copied the page processing function from FileUsageAuto-update I omitted the multiple replacements part. I'll work on including that. As for the wrong word replacement, holy crap. It looks like I missed a part of the regex when I adapted it as well. I guess I can blame that on half-spirited coding in the beginning when I was porting it to work with categories. I'll fix that asap. Thanks for the reports to make the script better! — Foodbandlt (talk) 00:02, December 23, 2014 (UTC)
Okay, I've fixed what you described here (hopefully). I'm not as familiar with category use cases as I am with image use cases. If you find a use case that it missed if you wouldn't mind leaving a link here so I can update the regex I would appreciate it. Working on link updating now. Thanks! — Foodbandlt (talk) 02:40, December 23, 2014 (UTC)
All right, it's done and uploaded. There are two new messages to translate if you wouldn't mind (marked with // NEEDS TRANSLATION under fr). One unfortunate part about these being categories and not images is that when a category name is used without it's surrounding brackets, like in a template parameter, there's no easy way to tell the difference between regular words and a category name. Generally those are edge cases as from what I've seen people call that bad practice, but regardless it still happens. I've removed that part of the regex so that it doesn't touch anything that's not inside of double brackets for now until we find more (obvious) use cases. Thanks for all of your help and feedback! — Foodbandlt (talk) 05:15, December 23, 2014 (UTC)


Currently this script is giving me an error and breaking my JS - the console reads "ReferenceError: LIR is not defined". – Ozuzanna 13:53, December 28, 2014 (UTC)

And this is why copy-pasting is dangerous. Lol. Thanks Oz! — Foodbandlt (talk) 15:43, December 28, 2014 (UTC)

Suggestion : default summary

Hi :) I've been using the script a lot and I think that it could be improved by allowing the use of a custom default edit summary.

By the way, Happy New Year! —Hulothe @fandom 22:16, January 1, 2015 (UTC)

PS : I'm very often (each time tbh) getting this error from the API : "internal_api_error_DBQueryError". It's very weird, the category on page does actually change but the pages for which I get this error stays in the old one. When mae=ke a manual change to categories on the page, it fixes the "bug".

All right, I've sent an S:C to Wikia about the API error for clarification. About the edit summary, are you talking about the "Updating Category:Blah -> Category:Blahh (automatic) summary when editing a page? Would you prefer to use the same reason that you input on the rename page? Or would you rather have a default specified before you import the script? If you want to specify a new default in a variable before the script, would being able to use the old and new category name be useful? — Foodbandlt (talk) 23:40, January 2, 2015 (UTC)
Wikia responded saying that they need more information about the error (which I honestly didn't know that there was). I've updated the script to include the error information in the message if you wouldn't mind copy-pasting the entire error message next time you come across it. It should be in the form of "Error code; error info". I'll send it to Wikia once I have that. Thanks! — Foodbandlt (talk) 19:51, January 5, 2015 (UTC)
Sorry for the late reply. What I mean is the #wpReason textarea, to be defined in a variable before the script. "Updating Category:Blah -> Category:Blahh (automatic)" summary for pages edits is fine. Maybe it would be useful to use this as a default summary for #wpReason, but sill make it customizable. Ok for the error, I hope someone will be able to fix that! —Hulothe @fandom 07:11, January 7, 2015 (UTC)

Alternative to Delete

It's not always the case that a bot is also an admin, which can mean old categories left undeleted. How about an option so that rather than deleting a category page or leaving it alone, its contents are replaced with {{Delete}} or something similar so it can be swept up later?JoshuaJSlone (talk) 14:16, January 21, 2015 (UTC)

Done. I've added the option to define what to replace the page contents with, rather than hard-coding it in. Let me know if you have any other suggestions or issues, thanks! — Foodbandlt (talk) 16:12, January 21, 2015 (UTC)

Still working?

Is this still working for anyone? I'm not sure when the last time I used it was, but I no longer see the Rename option on category pages.JoshuaJSlone (talk) 14:51, September 30, 2015 (UTC)

It appears to be working for me. What page are you on that it doesn't appear? — Foodbandlt (talk) 15:46, September 30, 2015 (UTC)
Sorry, seems I've barked up the wrong tree. This is the symptom I noticed, but it seems like none of the scripts in my bot account's global.js are loading right now for some reason.JoshuaJSlone (talk) 17:51, September 30, 2015 (UTC)
That was a recent chance that Wikia made. You need to check a checkbox in your bot's preferences to enable personal javascript. — Foodbandlt (talk) 17:56, September 30, 2015 (UTC)
Aha, that's it! I remember doing so for my main account, but forgot to for that one.JoshuaJSlone (talk) 18:05, September 30, 2015 (UTC)


add the code

Done. Thanks for contributing! — Foodbandlt (talk) 16:36, January 28, 2016 (UTC)

Not Found Error

Because of UserTags having an issue recently I've looked at my console errors and was alerted to something with this script (Failed to load resource: the server responded with a status of 404 (Not Found) or GET I import the script globally and the script indeed doesn't work for me (I've changed nothing). Not sure if this is a recent issue or has been there for a while. DEmersonJMFM 02:32, February 4, 2017 (UTC)

No longer an issue. DEmersonJMFM 00:09, February 5, 2017 (UTC)

Personal use

Why this script is tagged as "personal use" while other similar like FileUsageAuto-update are not? leviathan_89 @fandom 04:09, October 17, 2017 (UTC)

I tagged it that way because this script has the potential to do a lot more damage without requiring additional user rights (file moving) like the script you mentioned does. It can absolutely be used wiki-wide, I just didn't want to add sketchy "security" measures into this because ultimately they wouldn't work that well anyway. — Foodbandlt (talk) 19:01, November 20, 2017 (UTC)


I don't see the "rename" button translated in Italian even though it is. I'd also like to suggest the use of I18n-js for managing translation more easily and adding the new category name (with link) in the deletion summary. leviathan_89 @fandom 16:52, January 24, 2018 (UTC)

That's because the script wasn't using the translation for the edit dropdown link. Should now be fixed!
Just my opinion here, but I quite like the i18n system this script is using. By keeping each translation on a separate page, the script only loads the needed translation instead of having to load them all with only one ever being used. - OneTwoThreeFall talk 17:54, January 24, 2018 (UTC)
Yes that's good especially for scripts with a lot of translations. I only generally suggest using i18n-js simply because it bypasses the review process and it's easier to to use it to translated since it has context and side-by-side comparison. I wonder if the "a page per language" can be implemented for i18n-js, even if an option for very big scripts... leviathan_89 @fandom 20:49, January 24, 2018 (UTC)
It would mean we can't use a proper language fallback system if only "needed" language is loaded. If a message is available in pt but not in pt-br the script would either display undefined or have to load the other language too. And then if a message isn't available in pt-br either it would have to load en and so on... I think making one HTTP request that returns a lot of data is still faster than making multiple HTTP requests one after each other that return smaller parts of that data. -- Cube-shaped garbage can 20:58, January 24, 2018 (UTC)

500-per-run hard cap

I found while running this script on a few thousand images that there seems to be a hard cap of 500 edits per run. After 500, the script hangs, and the user must reload the page. The user then has to delete the destination category page and re-run the script. Wasn't a huge deal for me since I only ran it on a few thousand, but this will probably cause a lot of frustration for anyone running it on tens of thousands of files. Is there possibly a way to bypass this limit? —Bellamybug (talk) 15:56, January 10, 2019 (UTC)

Issue on non-English wiki

Hi! I come again because I have the same issue I described here. Since the move to on my French wiki, the script is not working anymore. Please, can someone update it? Lady Junky 00:35, January 29, 2019 (UTC)

Fetching page contents from API

The script has been stuck at this message on this wiki, anyone have a clue? --Light DaxterTalkpage 19:48, May 6, 2019 (UTC)

Have you tried refreshing the server cache by appending ?action=purge to the end of the URL? That's about all I can think of... It only happens on that wiki, huh? —RyaNayR (talkcontribs) 22:17:43, 6 May 2019 (UTC)
Oh I figured it out, I made the category a category of itself because reasons, and thus the script got stuck looping on forever lol. Oops. --Light DaxterTalkpage 13:01, May 7, 2019 (UTC)
I'm glad that you got it figured out! —RyaNayR (talkcontribs) 13:26:19, 7 May 2019 (UTC)

Can't replace categories with extra space

Hello everybody, just as a heads up the script is unable to rename a category if it has an extra space in it when being added to a page (i.e. [[Category:Images containing the character Kazuma Kuwabara ]]). 22px-Logo.svg.pngTyA_userpage_image.png Badge-VSTF.svg @fandom 10:41, February 4, 2020 (UTC)

Can't rename

Hello, I just added this code to my wiki and when I clicked it, it turned out a blank page. Please help. Ngialinh (talk) 04:54, August 20, 2020 (UTC)

Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+