Skip to main content

A script to organize photos by creation date into year/month/day folders.

Project description

Photo Organizer

TestsUpload ReleasePyPI version

Photo Organizer is a Python script that sorts photos from a source directory into a target directory based on their creation date. The script can organize photos into year, month, and optionally day subfolders. It also supports copying or moving files, recursive directory traversal, filtering by file extensions, and excluding files using regex patterns.

Features

  • Organize photos into year/month/day folders based on creation date
  • Move or copy files from the source to the target directory
  • Recursively traverse directories
  • Filter files by specified extensions
  • Exclude files from processing using regex patterns
  • Verbose logging for detailed information
  • Flexible folder structure with optional top-level year-month folders.

Usage

Prerequisites

  • Python 3.x

Installation

Install the package using pip:

pip install photo-organizer

In alternative you can use it with Docker:

docker run -ti \
    -v <your-photo-source-directory>:/source \
    -v <your-photo-target-directory>:/target \
    ghcr.io/Supporterino/photo-organizer:latest /source /target

Running the Script

photo-organizer [-h] [-r] [-d] [-e [ENDINGS [ENDINGS ...]]] [-v] [-c] [--no-year] [--exclude EXCLUDE_PATTERN] source target

Arguments

  • SOURCE_DIRECTORY: The source directory containing the photos
  • TARGET_DIRECTORY: The target directory where the photos will be organized

Options

  • -r, --recursive: Sort photos recursively from the source directory
  • -d, --daily: Organize photos into daily folders (year/month/day)
  • -e, --endings: Specify file endings/extensions to copy (e.g., .jpg .png). If not specified, all files are included
  • --exclude: Provide a regex pattern to exclude matching files from being processed
  • -v, --verbose: Enable verbose logging. -vv means more verbose.
  • -c, --copy: Copy files instead of moving them
  • --no-year: Do not place month folders inside a year folder; place them top-level with the name format YEAR-MONTH

Examples

Move all files from source to target, organizing by year and month:

photo_organizer /path/to/source /path/to/target

Move all files recursively and organize by year/month/day:

photo_organizer /path/to/source /path/to/target -r -d

Copy only .jpg and .png files:

photo_organizer /path/to/source /path/to/target -e .jpg .png -c

Exclude files matching a specific regex pattern:

photo-organizer /path/to/source /path/to/target --exclude "^ignore|\.tmp$"

Enable verbose logging:

photo_organizer /path/to/source /path/to/target -vv

Move photos to top-level year-month folders without a year parent folder:

photo-organizer --no-year /path/to/source /path/to/target

Combine options to copy .jpg and .png files recursively into daily folders with verbose logging:

photo-organizer -r -d -e .jpg .png -vv -c /path/to/source /path/to/target

Development

To contribute to this project, follow these steps:

  1. Clone the repository.
  2. Install dependencies.
  3. Make your changes and add tests.
  4. Submit a pull request.

Logging

The script uses Python's logging module to provide detailed information about the operations performed. By default, the logging level is set to INFO. Use the -v or --verbose flag to enable INFO level logging and -v or --verbose --verbose`` for DEBUG` level logging for more detailed output.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes. Ensure that your code adheres to the existing coding standards and includes appropriate tests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

photo_organizer-1.6.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

photo_organizer-1.6.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file photo_organizer-1.6.0.tar.gz.

File metadata

  • Download URL: photo_organizer-1.6.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for photo_organizer-1.6.0.tar.gz
Algorithm Hash digest
SHA256 bc8158ada392ee39a55b8d17a6ac35ed99ef58a9ae95da04fa6cdd75d0a1aa02
MD5 d3aaafa07149e9ca11e9e4c4198e342a
BLAKE2b-256 2bed1c6ccd481cf89d2b01e381004ea1852878fd19c2ce29b2e412b7019f134d

See more details on using hashes here.

File details

Details for the file photo_organizer-1.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for photo_organizer-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c54c7f3be1dabe519d1c07883c6e0ffbe0e886e3afc0571fd005e4f24ce32589
MD5 66c38b26e12dba502340c8da7b350d3f
BLAKE2b-256 7a705acd3d5329fcde0488a49f6be09acc1ceae0c4653a879bfc8e8dd8f7785e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page