User:Nichalp/Upload script

Warning sign This page requires updating because: not working? fails to log-in In doing so, you could add a timestamp to the page.
Please notify the uploader with {{subst:update-note|1=User:Nichalp/Upload script|2=not working? fails to log-in}} ~~~~
Nichalp's upload script
Script information
Author Nichalp
Talk Talk
Main page Upload script
Language Perl
Version 1.0 + 1.3.1
Description Automates mass uploading of images with metadata
Licence GPLv3
Formats supported JPG/JPEG
Scripts
Scripts

csv creator.pl
upload.pl

Help files
Running the script Main page
Installation Installation
Spreadsheet information csv fields explained
CSV example upload.csv
Spreadsheet tips Spreadsheet tips
Nichalp's Upload Script


Nichalp's Upload Script is a script written in Perl that helps you upload your photographs en masse to commons. Instead of manually adding a description, the date, categories, licence information, and geo-templates to each image, you can write it just once, and the script will format it as wiki-syntax for the entire series of images you want to upload. This is particularly useful if you have to fill in similar information for a series of images. But that's not all! You can do so much more.

The script can be used on Microsoft Windows and GNU/Linux. It has not been tested on Mac. If you have a fast internet connection, or plan to upload smaller files, consider getting a bot account to prevent the script from flooding the recent changes list.

Features edit

  • Rename the images on-the-fly.
  • Rotate images on-the-fly.
  • Autoformat wiki-syntax, so you do not have to worry about template parameters.
  • Embeds your name, caption, and GPS data in the Exif information.
  • Add descriptions in several languages.
  • Adds the {{Location}} template if GPS coordinates are supplied.
  • (Optional) Adds the {{Photo Information}} template
  • (Optional) Adds the {{Flickr-self}} template, if you have upload the same image to Flickr.
  • Creates a gallery.txt file with the list of image in wiki-syntax. This allows you to copy-paste the text into an image gallery.
  • Rigorous checking to make sure that you have added a category, description, and licence to each image, and if parameters are in range.

How it works edit

There are two scripts that need to be used.

  1. The first script is used to scan all JPEG images in the directory, and store the information such as date, camera information and so on into a CSV (comma separated value) file. The image names and column headings are automatically added.
  2. Using any Spreadsheet software, fill up the various fields such as description, new name, category and so on.
  3. Run the second script to read the CSV file data, and upload the corresponding file to commons.

Disclaimers edit

  • This script is largely untested for all possible permutations and combinations. Use at your own risk. See also #Bugs.
  • Back up all images before uploading.
  • The script will automatically upload over existing images. Make sure you check if the file name you supplied does not exist in commons.
  • The script does not check if you have renamed the file correctly. Beware of introducing duplicate file names when renaming.
  • By default, your commons password is visible on the monitor when asked to enter it. To hide it use: perl upload.pl - secure
  • This script is currently limited to uploading only self-created photographs in JPG/JPEG format. Support for other formats coming soon.

Essentials edit

You must have the following installed to run the scripts:

  1. Perl
  2. ExifTool library
  3. Text:CSV parser library
  4. libjpeg.

Read the installation guide to install the above for Microsoft Windows or Linux.

Executing the script edit

 
Script execution in progress.
  1. Create a new folder.
  2. Copy the images you want to upload into the above folder.
    •   Note:- Images must contain the only following file extensions (.JPG, .jpg, .jpeg, .JPEG) to be picked up by the script. (PNG and other filetype support to come later)
    •  Caution:- Make sure you have backups of all images to be uploaded
  3. Copy the perl scripts: csv_creator.pl and upload.pl into the folder.
  4. In the command line (Terminal in Linux/DOS in Windows), navigate to the above folder.
  5. Run csv_creator.pl from the command line by typing: perl csv_creator.pl
    A CSV (comma separated value) file, upload.csv is created in the folder. The CSV file includes the header line, the list of image file names in the folder, and the corresponding image Exif information.
  6. Add the necessary information you want to the CSV file. To know how to format data in the CSV file, please read CSV fields explained. You can edit the data in your favourite spreadsheet software such as LibreOffice Calc or Microsoft Office Excel.
  7. Save the CSV file.
  8. Run upload.pl from the command line by typing: perl upload.pl
    • To specify your CSV file location, use perl upload.pl file.csv
    • To hide your password while typing it, use perl upload.pl - secure
    • To tell Perl to not load huge images/files into memory, but read them directly from disk while uploading, use perl upload.pl - - disk
    • If your CSV file does contain any UTF-8 (non-ASCII) characters, use perl upload.pl - - - utf8
  9. You are then asked to enter your username and password.
  10. The script then uploads the image along with the associated metadata. Errors if any, are logged in debug.txt.
  11. A gallery.txt file is created in the same folder. This file contains the list of images marked up with the gallery wiki syntax. If you need, you can use the text to create image galleries.

Bugs edit

  1. The last version will give a strange declaration error concerning $csv. See User talk:Nichalp/Upload script for a fix.
  2. Enabling it for different file types like .png is possible. See User talk:Nichalp/Upload script.
  3. Using permission "1" or "7" will result in unwanted outcomes. See User talk:Nichalp/Upload script for a fix.
  4. May hang if the computer is unattended for a long time. Solution: Check the last file uploaded. Quit the program, open the CSV file, delete all entries up to the last uploaded file. And restart the process.
  5. HTML formatting may appear in the command prompt. Reason unclear. Possible solution: Avoid editing in commons when uploading.

Credits edit

See Also edit