Image Sorting Tool

Topics: PythonCommand-Line
Published on: September 19, 2025

Having been taking many thousands of pictures over the year, it’s crucial to have some way of structuring the photos to keep the upper hand. My approach was to make a first layer of folders for the year, then subfolders for the months, and another layer of subfolders for the days, which will look like:

photos/
├── 2025/
│   ├── 2025-01/
│   │   ├── 2025-01-13/
│   │   │   └── ...
│   │   └── 2025-01-26/
│   │       └── ...
│   └── 2025-02
└── 2024/
    └── 2024-03/
        └── 2024-03-17/
            └── ...

the only command line tool that is able to do that is exiftool, but I wanted to do my own.

The Sorter

That’s how the sorter was born. A python based command line tool that sorts images and other files into folders, according to their date. The tool is open source on GitHub, in this repository.

Example Command

Here a short example on how the tool works, if the command is run inside the repository.

Note: Always use the --dry flag, unless you want changes written to disk.

python3 main.py --input . -r --output . --pattern "year-%Y" "%y-%b" --dry

The user will be asked prompts on how to deal with collisions, as in this example the sorting would lead files with the same name placed in the same folder. One can either abort, only have the first appearance of the file copied or moved, or have the tool rename the files.

This command would sort the file in the repository into the folders:

 year-2025/
    25-Sep/
      requirements.txt
      ...
    25-Jun/
      python3
      ...

Explanation of the command:

Top ↑