User Tools

Site Tools



The script will take a directory tree containing jpg images, read the EXIF Time/Date stamp from each image, then sort the images into a directory.
It will either make a single numbered set of images (0001.jpg, 0002.jpg, 0003.jpg, etc.) in the destination directory, or will create a sub directory in the destination directory for each date (YYYY-MM-DD) and then create a numbered set in each dated directory.
If using sub directories, files that do not have an EXIF Time/Date stamp will be sorted into the 9999-99-99 sub directory.
If not using sub directories, files that do not have an EXIF Time/Date stamp will be put at the end of the file set.

Version 2.0 uploaded 2011-03-01.
Version 2.0 now checks for files named .jpg and .jpeg to process.
Version 2.0 will properly handle files with the “$” character in the name. is copyright Mark D. Montgomery II and is provided under the GPL 3 or later license.

This script is provided as is with no warranty implied or expressed, use at your own risk.

Note: This script WILL OVERWRITE DESTINATION FILES without asking, so be sure to specify your destination directory correctly.


Program Syntax: [start directory] [destination directory] [use sub dirs (Y/N)]

Example Syntax: MyPics SortedPics Y


  • perl
  • List::MoreUtils
  • Term::ANSIColor (to support color output of the help information)
  • find
  • ls
  • exiftool
  • mkdir
  • cp

Processing Sequence

  • Generate an array containing the full tree structure to process
  • Walk the array and process each directory
    • Read the directory
    • Process each file found
      • Check if the file is a jpg or not to determine whether to process it
      • Read the EXIF date/time information
      • Parse the information and create variables for date and time parts
      • Write the date and time and filename into a files array
  • Process the files array
    • Sort the array
    • Create the destination directory if it does not exist
    • Check if we are creating sub directories or not
      • If not using sub directories (Need to check this function to make sure they really are in order)
        • Create a counter variable
        • Walk through the array
        • Copy each file to the destination filename based on the current counter
      • If using sub directories
        • Walk the files array and push the dates into a dates array
        • Uniq the dates array
        • Walk the dates array and create the directories
        • Create counter and last-used date variables
        • Walk the files array
          • Determine the destination directory for the file
          • Determine if the file date is different from the previous file date to see if we are in a new dated set or not
            • If the date is different, set the counter back to one to start a new set
          • Update the last-used-date variable
          • Copy the file to the appropriate name in the appropriate directory
          • Update the counter variable


code/picsort.txt · Last modified: 2017/07/02 10:11 (external edit)