Commons:PetScan/Generate list of Commons files

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Translate this page; This page contains changes which are not marked for translation.
A step-by-step guide on retrieving a list of Commons file names using the PetScan tool  
 Launch PetScan First of all, launch the PetScan tool!
You will start the tool inside the first tab ('Categories').
  • Make sure you select Wikimedia Commons here, by clicking on Commons.
  • Categories: Type or paste one or more Commons category names here which contain the file names you want to retrieve. Omit the Category: prefix.
    • You can indicate the depth with which you want to retrieve files from the category tree. In the example shown on the left, we are retrieving files that are directly in the category Uploaded with iNaturalist2Commons AND that have the category Lepidoptera of Australia (or one of its subcategories, up to three levels deep).
  • Combination: if you select the radio button 'Intersection', you will only retrieve those files that are in all your chosen categories - usually a smaller number of files. If you select the radio button 'Union', you will retrieve a larger number of files that are in either of the categories you entered. Usually 'Intersection' is the logical option.
Go to the next tab in the tool ('Page properties').
  • Namespaces: Deselect the first (unnamed) checkbox and select the File checkbox. This indicates that you only want to retrieve file names (not categories, not gallery page titles, etc).
If you like, you can now already click on the 'Do it!' button to verify that you are indeed retrieving the right file names.
In some cases, it is convenient to retrieve the file names as plain text, or in another format. You can adjust that in the last PetScan tab ('Output').
  • Format: for instance, select the 'Plain text' radio button.
  • Scroll down and click on the 'Do it!' button again. You will now see the list of file names as plain text.
If you chose 'Plain text' as output format, you will get a list of file names in plain text. If you want full URLs – for example so that you can open many of these files at once in new tabs using drag and drop – you need to use the search and replace function of a text editor like Visual Studio Code to prepend https://commons.wikimedia.org/wiki/ before File:. The line-breaks may also need to be replaced and spaces need to be replaced with _.

The following link gives you the above-shown example, with HTML output: https://petscan.wmflabs.org/?psid=22129478