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 type | Example URL | How files appear |
|---|---|---|
| Category pages | commons.wikimedia.org/wiki/Category:… | Gallery of thumbnails |
| Special:ListFiles | commons.wikimedia.org/wiki/Special:ListFiles/Username | Sortable table |
| Special:Search results | commons.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
| Control | Description |
|---|---|
| Template name input | Type 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 dropdown | Choose where in the file's wikitext the template will be placed when adding. See Insert position below. |
| ✔ All button | Selects all visible files on the current page. |
| ✘ None button | Deselects all selected files. |
| file(s) selected counter | Shows how many files are currently selected. |
| + Add button | Adds the template to all selected files. Skips any file that already has it. |
| - Remove button | Removes the template from all selected files. Skips any file that does not have it. |
| ↩ Revert last batch button | Appears 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
- Type the template name in the input box (e.g.
Personality rights). - Select the files you want to edit.
- Choose the insert position from the dropdown (default: Before Licensing).
- 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
- Type the template name in the input box.
- Select the files you want to edit.
- 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:
| Option | Where the template is inserted | Recommended for |
|---|---|---|
| Top of page | Very first line of the wikitext | Urgent maintenance tags (e.g. {{Delete}}) |
| Before Licensing (default) | Immediately before the == Licensing == section heading | Most templates on Commons file pages (e.g. {{Personality rights}}, {{Extracted}}) |
| Before categories | Just before the first [[Category:…]] line | Categorisation-related templates |
| Bottom of page | Last line of the wikitext | Tracking 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:
| Badge | Meaning |
|---|---|
| ✔ added | Template was successfully added |
| ✔ removed | Template was successfully removed |
| ⚠ exists | File already had the template — skipped (add mode) |
| ⚠ absent | File did not have the template — skipped (remove mode) |
| ✘ error | An 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
- Open the relevant category page.
- Click the Templ-a-lot header to expand the panel.
- Type
Personality rightsin the template input. - Set position to Before Licensing (already the default).
- Click ✔ All to select all thumbnails.
- Click + Add.
Tagging files for deletion review
- Navigate to
Special:ListFiles/Usernamefor the relevant uploader. - Expand the panel, type
Delete, set position to Top of page. - Select the relevant rows via the checkbox column.
- Click + Add.
Removing a maintenance template after an issue is resolved
- Open the category page where the files are listed.
- Type the template name (e.g.
Review). - Select the files.
- Click - Remove.
Comparison with Cat-a-lot
| Feature | Cat-a-lot | Templ-a-lot |
|---|---|---|
| Add/remove categories | ||
| Add/remove templates | ||
| Works on category pages | ||
| Works on Special:ListFiles | ||
| Skip-if-exists logic | ||
| Revert last batch | ||
| Parallel processing | ||
| Insert position control | N/A | |
| Done notification |
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