Commons:Command-line upload
It is possible to upload to Wikimedia Commons using command-line tools.
Tools to upload local files
editScript | Dependencies | Batch upload | {{Information}} support |
---|---|---|---|
<tvar name=upload.pl>Nichalp's Upload Script</tvar> | Perl | Yes | 7 licenses |
<tvar name=anuta>Anuta</tvar> | Perl, Python and csv_creator.pl |
Yes | 7 licenses |
<tvar name=simple-commons-uploader>Simple Commons Uploader</tvar> | Python | Yes | only Cc-by-sa-2.0 |
<tvar name=upload.py>upload.py</tvar> from <tvar name=pywikibot>Pywikibot</tvar> | Python | No | none |
Nichalp's upload script
editA Perl script that creates a CSV file with the list of photographs in a folder. Enter all information, such as description, licence, category, latitude, longitude and so on. Also embeds certain Exif data to the photograph such as GPS data, name, licence etc. In addition, you can also rotate and rename it on-the-fly.
Wmigda's upload script
editA Python version of Nichalp's upload script but that is dependent on the upload.csv-file that one of Nichalp's two Perl script generates.
Requirement: At least Perl and Python and one of Nichalp's two scripts, see documentation for further details
Fastily's upload script
editA Python program which can upload whole folders on your computer with basic information and a category (determined by the name of the enclosing folder).
Tools to upload files from other websites
editFlickrripper is a free Python program for easy upload of large numbers of images from Flickr to Wikimedia Commons. The program is documented in mw:Manual:Pywikibot/flickrripper.py.
Python Wikipedia Bot
editThe python framework includes various file upload tools. These tools require installing Python and the pywikibot framework. If each upload is checked prior to upload (see verifyDescription option below), it isn't considered a bot.
For detailed information on its usage:
To login with this tool, your configuration file needs the following settings.
family = 'commons' mylang = 'commons' usernames['commons']['commons'] = 'nick'
Usage:
- Upload.py – to upload files to Commons.
- Imagecopy.py – image transfer in local wiki to Commons.
- Nowcommons.py – image delete in local wiki already in Commons.
# -*- coding: utf-8 -*-
import sys
import pywikibot
from pywikibot.specialbots import UploadRobot
def complete_desc_and_upload(filename, pagetitle, desc, date, categories):
#complete this once if applies to all files
description = u"""{{Information
|Description = {{en|1=""" + desc + """}}
|Source = <!-- if applicable: {{own}} --->
|Author = <!-- your name: --->
|Date = """ + date + """
|Permission =
|other_versions =
}}
=={{int:license-header}}==
<!-- your license --->
""" + categories + """
[[Category:Taken with camera 123]]
"""
url = [ filename ]
keepFilename = False #set to True to skip double-checking/editing destination filename
verifyDescription = True #set to False to skip double-checking/editing description => change to bot-mode
targetSite = pywikibot.getSite('commons', 'commons')
bot = UploadRobot(url, description=description, useFilename=pagetitle, keepFilename=keepFilename, verifyDescription=verifyDescription, targetSite=targetSite)
bot.run()
def main(args):
#list each file here
filename = """testimage-1.jpg"""
pagetitle = """testimage-1-from asdfasdfa.jpg"""
desc = """Mount St Helens viewed from ... in the rain"""
date = "2010-04-07"
categories = """[[Category:Locality]]
[[Category:Theme]]
[[Category:View type]]
[[Category:Feature1]]
[[Category:Feature2]]"""
complete_desc_and_upload(filename, pagetitle, desc, date, categories)
#sample with: - local file name identical to file name at Commons
# - date as previous file
# - less quotes (no CR or " in fields)
filename = "testimage-2.jpg"
pagetitle = filename
desc = "Mount St Helens as seen from ... at sunset"
categories = "[[Category:Locality]] [[Category:Theme]] [[Category:View type]] [[Category:Feature1]] [[Category:Feature2]]"
complete_desc_and_upload(filename, pagetitle, desc, date, categories)
if __name__ == "__main__":
try:
main(sys.argv[1:])
finally:
pywikibot.stopme()
For other tools based on pywikipediabot, see multichill/bot and erfgoedbot.
BotClasses.php
editSome bots, like User:BrooklynMuseumBot, were written in PHP based on BotClasses.php