Jump to content

User:Wilfredor/commons-batch-uploader

From Wikimedia Commons, the free media repository
commons-batch-uploader
The form of one queued file
DescriptionDescribe a batch of files first, upload them in a background queue
AuthorWilfredor
StatusExperimental
Updated2026-08-25
SourceUser:Wilfredor/commons-batch-uploader.js

Overview

[edit]

commons-batch-uploader is an alternative to Special:UploadWizard for large batches. UploadWizard transports every file to the upload stash before it opens the Describe step, so a batch of several hundred files means waiting at a progress bar before any metadata can be typed.

This script inverts that order:

  1. Pick the files. Nothing is transported yet.
  2. Write the metadata immediately, per file, or by copying the fields of one file down to every file below it.
  3. Press Publish. A background queue uploads each file and publishes it as soon as its own metadata is ready, three files at a time.
Copying the metadata of one file down the queue, one checkbox per field

Because publication follows the upload immediately, the six-hour lifetime of the upload stash is never a factor, unlike the describe-after-upload order, where a long description session can outlive the stashed bytes it describes.

What survives a reload

[edit]

The queue lives in the browser's IndexedDB: metadata, per-file state and the filekey of anything already stashed. If the tab is closed, the browser crashes or the connection drops, reopening the tool restores every description you typed. File contents are deliberately not stored. A batch is easily several gigabytes and the storage quota is not. Files added with Add a folder are found again by themselves, because the browser remembers the permission for that folder; files dropped one at a time have to be picked again, and are matched back to their metadata by name, size and modification date.

Notes and limitations

[edit]
  • The tab must stay open while the queue runs. A user script cannot register a service worker, so there is no way to keep uploading in the background.
  • Warnings are not suppressed when a file is stashed. A duplicate or a taken name is shown before publication, with a "Publish anyway" button.
  • Destination names are checked against Commons in batches of fifty before anything is transported.
  • The queue starts paused: nothing leaves the browser until Publish is pressed, and "Preview wikitext" shows exactly what will be published.
  • Chunked transport, offset continuation and assembly polling come from MediaWiki core's own mw.Api upload module, not from a reimplementation.

Installation

[edit]

Add this line to Special:MyPage/common.js and reload with Ctrl+ Shift+R:

importScript('User:Wilfredor/commons-batch-uploader.js');