FANDOM


ListFiles is a site-wide and user script for file management. It provides a form for building URL's to query the MediaWiki API, as well as an extensive list of options for formatting the data after retrieval. Some things you can do with this script are:

  • alphabetically enumerate all files on a wiki
  • search for all files that have a certain prefix
  • get a list of files larger than 1 MB
  • generate new lists without reloading the page
  • save and reset your settings
  • sort files by name, uploader, timestamp, width, etc.
  • lists generated in raw text can be parsed and used with other applications such as bots

Some things you cannot do with this script are:

  • easily find all files uploaded recently (use the Special:NewFiles special page instead)
  • find all .png images on a wiki. The aimime parameter could be used to search for files by mime type... but unfortunately it's server-intensive and is disabled across FANDOM.

Installation

See also: Help:Including additional CSS and JS, Help:Advanced CSS and JS
  • For site-wide use, an administrator can add the line below to the wiki's MediaWiki:ImportJS page. Note that JavaScript must be enabled on the wiki.
dev:ListFiles/code.js
  • For personal use, add the code snippet below to your global.js page (for use on all wikis) or your common.js page on your wiki (for use on a single wiki). Note that personal JS must be enabled for your account.
importArticles({
    type: 'script',
    articles: [
        'u:dev:ListFiles/code.js',
    ]
});
importArticles — Best Practices for installing JavaScript on FANDOM
The importArticles statement is designed to combine multiple HTTP requests into a single data transfer, allowing multiple scripts to load and execute faster. If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements. Click "Expand" to learn how to efficiently batch import scripts to speed up performance and make your code look cleaner. One other approach is by using the MediaWiki:ImportJS.
If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! By batch importing a collection of scripts with a single import, your JavaScript code will load faster and look cleaner. Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.
Multiple imports — messy and slow One import — clean and efficient
importScriptPage('AjaxRC/code.js','dev');
 
importScript('MediaWiki:localScript.js');
 
importArticle({
  type: 'script',
  article: 'u:dev:FloatingToc/code.js'
});
 
importScriptPage('page1.js', 'wikiname');
 
importScriptPage('page2.js', 'wikiname');
importArticles({
    type: 'script',
    articles: [
        'u:dev:AjaxRC/code.js',
        'MediaWiki:localScript.js',
        'u:dev:FloatingToc/code.js',
        'u:wikiname:page1.js',
        'u:wikiname:page2.js'
    ]
});
Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.
But there's much more to importArticles than just this! For more examples and advanced usage, see the help page at Help:Including additional JavaScript and CSS.

Demo

A live demo of this script can be seen and used at w:c:terraria:Project:ListFiles.

See also, examples of the "raw text filenames" feature:

Usage

Once the ListFiles script is installed, you can visit Project:ListFiles on your wiki to see the script in action. It will also load on subpages in the User: namespace that have 'ListFiles' in the title, e.g. User:Username/ListFiles – this is designed to be useful for people who have the script in their global.js.

If you'd like to force this script to load on different page, simply edit whichever page you want and place the following wikitext there:

<div id="ListFiles-container">This page provides a form to query the MediaWiki API for images and requires JavaScript in order to function. See [[w:c:dev:ListFiles]] for more information.</div>

The id="ListFiles-container" is the important part. The ListFiles script will look for a container that has that id, so if you put such a container on any page, the script will run on that page.

Raw text list of filenames

A side feature of this script is that it provides a raw text list of filenames on the following special pages:

These raw text lists can be useful for someone with a bot or automation script. For example, if you wanted to delete unused images on your wiki, you could visit Special:UnusedFiles and copy the raw text list of files provided by this script, and then feed that input through the AjaxBatchDelete script to easily mass delete them.

Updates

02 January 2017
Dai ca superman⋅ added AjaxRC support for script
23 January 2014
ShutterBat started translation in spanish of code (raw filenames by the moment specially for advanced version of QuickTools)
7 February 2013
Mathmagician extended the "raw list of filenames" feature to Special:UncategorizedFiles, thanks to Revitalizer's note on the talk page.
2 February 2013
Mathmagician extended the "raw list of filenames" feature to the new Special:UnusedVideos page.
29 January 2013
Mathmagician added feature for raw list of filenames at Special:UnusedImages (helpful for people who want to do a batch delete to clean up unused files).
30 October 2012
Mathmagician added feature for raw list of filenames at Special:ListFiles (convenient way to get a list of all files uploaded by a single user).
22 October 2012
Mathmagician added an image preview feature when hovering over filename links in the results table.
25 September 2012
Mathmagician created.
6 July 2017
Game Moderator prevented distorting the image, and perfectly aligns it in the center on hover.
Text above can be found here (edit)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.