User:Suyash.dwivedi/userscripts/Templ-a-lot

Templ-a-lot

Templ-a-lot

Templ-a-lot is a userscript for Wikimedia Commons that allows you to add or remove any template to/from multiple files in bulk — directly from a category page or your file list — without opening each file individually.

It is inspired by Cat-a-lot, which does the same for categories. Unlike Cat-a-lot, Templ-a-lot focuses on templates (such as {{Delete}}, {{Review}}, {{Personality rights}}, or any custom template), a feature Cat-a-lot does not currently support.

Installation

Add the following line to your Special:MyPage/common.js:

importScript( 'User:Suyash.dwivedi/userscripts/Templ-a-lot.js' );

Save the page, then bypass your cache (Ctrl+Shift+R or Cmd+Shift+R).

The panel will appear automatically on supported pages.

Where it works

The Templ-a-lot panel appears automatically on:

Page typeExample URLHow files appear
Category pagescommons.wikimedia.org/wiki/Category:…Gallery of thumbnails
Special:ListFilescommons.wikimedia.org/wiki/Special:ListFiles/UsernameSortable table
Special:Search resultscommons.wikimedia.org/wiki/Special:Search?…Gallery of thumbnails

The panel

The panel is a compact floating box fixed to the bottom-right corner of the screen. It is designed to stay out of the way of the Structured Data (SDC) button and the Cat-a-lot button.

  • Click the 📋 Templ-a-lot header bar to expand or collapse the panel.
  • When collapsed, it takes up almost no space.

Panel controls

ControlDescription
Template name inputType the name of the template you want to add or remove. You can write it as Delete, {{Delete}}, or Template:Delete — all are handled the same way.
Insert at dropdownChoose where in the file's wikitext the template will be placed when adding. See Insert position below.
✔ All buttonSelects all visible files on the current page.
✘ None buttonDeselects all selected files.
file(s) selected counterShows how many files are currently selected.
+ Add buttonAdds the template to all selected files. Skips any file that already has it.
- Remove buttonRemoves the template from all selected files. Skips any file that does not have it.
↩ Revert last batch buttonAppears after a batch finishes. Undoes all edits made in the last run, restoring each file's previous wikitext.

Selecting files

On category pages and search results

Click any thumbnail image to select or deselect that file. Selected thumbnails show a blue checkbox () in the top-left corner.

On Special:ListFiles

A ☐ checkbox column is added to the left side of the file table. Click the checkbox cell or the thumbnail cell in any row to select it. Selected rows are highlighted in blue.

You can also use ✔ All to select every file on the page at once.

Adding a template

  1. Type the template name in the input box (e.g. Personality rights).
  2. Select the files you want to edit.
  3. Choose the insert position from the dropdown (default: Before Licensing).
  4. Click + Add.

Templ-a-lot will open each selected file, check whether the template is already present, and:

  • Add the template if it is not there yet → badge shows ✔ added
  • Skip the file if the template already exists → badge shows ⚠ exists

Removing a template

  1. Type the template name in the input box.
  2. Select the files you want to edit.
  3. Click - Remove.

Templ-a-lot will check each file and:

  • Remove all instances of the template if found → badge shows ✔ removed
  • Skip the file if the template is not present → badge shows ⚠ absent

Insert position

When adding a template, the dropdown lets you choose where it is placed in the wikitext:

OptionWhere the template is insertedRecommended for
Top of pageVery first line of the wikitextUrgent maintenance tags (e.g. {{Delete}})
Before Licensing (default)Immediately before the == Licensing == section headingMost templates on Commons file pages (e.g. {{Personality rights}}, {{Extracted}})
Before categoriesJust before the first [[Category:…]] lineCategorisation-related templates
Bottom of pageLast line of the wikitextTracking or assessment templates

If the chosen landmark (e.g. the Licensing heading) is not found in a file's wikitext, the template is added at the bottom as a fallback.

Progress and results

While the batch is running, the progress line shows:

5 / 20 processed (3 running…)

Each file gets a small status badge on its thumbnail or in the table's Status column:

BadgeMeaning
✔ addedTemplate was successfully added
✔ removedTemplate was successfully removed
⚠ existsFile already had the template — skipped (add mode)
⚠ absentFile did not have the template — skipped (remove mode)
✘ errorAn API error occurred for this file (check your permissions)

When the entire batch finishes:

  • The panel header briefly turns green
  • A summary banner appears: ✅ 5 added · 0 removed · 1 skipped
  • A short audio cue plays (if your browser allows it)
  • The detailed log inside the panel lists every file and its outcome

Reverting a batch

After any batch run, the ↩ Revert last batch button appears. Clicking it restores every file that was edited in that run to its previous wikitext. Files that were skipped are not affected.

^

Configuration

Advanced users can customise behaviour by adding a preferences object to their Special:MyPage/common.js before the importScript line:

window.templALotPrefs = {
    position:    'before-licensing', // default insert position
    minor:       true,               // mark edits as minor
    watchlist:   'nochange',         // 'nochange', 'watch', 'unwatch', 'preferences'
    concurrency: 3,                  // how many files are processed simultaneously
    summary:     'Adding template via Templ-a-lot'  // custom edit summary
};
importScript( 'User:Suyash.dwivedi/userscripts/Templ-a-lot.js' );

Common use cases

Adding {{Personality rights}} to a batch of portrait photos

  1. Open the relevant category page.
  2. Click the Templ-a-lot header to expand the panel.
  3. Type Personality rights in the template input.
  4. Set position to Before Licensing (already the default).
  5. Click ✔ All to select all thumbnails.
  6. Click + Add.

Tagging files for deletion review

  1. Navigate to Special:ListFiles/Username for the relevant uploader.
  2. Expand the panel, type Delete, set position to Top of page.
  3. Select the relevant rows via the checkbox column.
  4. Click + Add.

Removing a maintenance template after an issue is resolved

  1. Open the category page where the files are listed.
  2. Type the template name (e.g. Review).
  3. Select the files.
  4. Click - Remove.

Comparison with Cat-a-lot

FeatureCat-a-lotTempl-a-lot
Add/remove categories Support Does not support
Add/remove templates Does not support Support
Works on category pages Support Support
Works on Special:ListFiles Does not support Support
Skip-if-exists logic Support (for categories) Support (for templates)
Revert last batch Support Support
Parallel processing Does not support Support (3 concurrent)
Insert position controlN/A Support (4 options)
Done notification Does not support Support (flash + sound)

Limitations

  • Templ-a-lot only processes files visible on the current page. For categories with many files, you may need to repeat the process across multiple pages.
  • You must be logged in and have edit rights on the files you are modifying.
  • The script does not currently support editing file pages on other wikis — it works on the wiki where the script is installed.
  • Revert is available only for the most recent batch.

Feedback and bugs

Please report issues or suggestions on the talk page of the script author.

Category:User scripts Category:Wikimedia Commons tools
Category:User scripts Category:Wikimedia Commons tools