Topic on Manual talk:Pywikibot

How to upload images to commons via command line?

12
TiagoLubiana (talkcontribs)

I am trying to do this for ages, but there is a lot of old information and misdirections.


I just want to upload a file via command line. Can someone here point me to a clear reference resource where I can really learn how to do it?

sorry about the angry tone, lots of ours of failure.

~~~~

Dvorapa (talkcontribs)
TiagoLubiana (talkcontribs)

In the end it all worked by:


Installing pywikibot via pip

Adding user-config.py file to the same folder as upload.py (and the directory of the files to upload too)

Running the uploads script


I was not able to specify some things, though, like wikidata items depicted, or choose the proper license, or adding a legend. Any tips on that?

Thanks!

Akbarali (talkcontribs)

Can anyone prepare the video tutorial of uploading photos using command line (python) into Wikimedia Commons

This post was hidden by Dvorapa (history)
Dvorapa (talkcontribs)

Not everything is supported by Pywikibot currently, see T223820. You can update upload.py script or write your own script using this brief manual, this basic template and this api module if you need specific feature not yet supported by Pywikibot. You could also propose a patch to Pywikibot if you manage to fix any of these.

Hbf878 (talkcontribs)

There is a parameter that allows for adding a file description string; this will become the wiki code of the Commons page of the file that you uploaded. By the way, the best description of parameters is to be found in upload.py itself, in my opinion. It's more clear than the documentations online.

python3 pwb.py upload "path/to/some_file.png" -summary:"uploaded with pywikibot" "source code string of the file page" -ignorewarn -always -keep

So in the source code string, you can include everything that you usually find on a Commons page (in wiki syntax), like filedesc with the information template, the license-header with the license template of your choice and categories. --Hbf878 (talk) 14:56, 21 April 2020 (UTC)

TiagoLubiana (talkcontribs)

Okay, thank you for the answers!

I will take a look and try to figure a way of doing it.

Reply to "How to upload images to commons via command line?"