Search code examples
mediawikipywikibot

How to add a category to a list of files using Pywikibot and category.py?


I have a text file (in.txt) containing a list of Wikimedia Commons files and I want to add the category [[Category:Fruits]] to all of them, how can I do that?

I can't find the option to specify the name of the category, so the script is prompting me for the name of the category. But that's quite annoying, I need to specify the name of the category to add in the script that runs Pywikibot.

For the moment, my script looks like this:

python pwb.py category add -file:in.txt

Solution

  • The parameter is ̀-to:.

    Your comment should looks like

    python pwb.py category add -file:in.txt -to:Fruits
    

    Note: if you have a lot of files in your list, ie. > 200, please consider using a botflag.