Skip to main content

A tool to sort/organize files recovered by the PhotoRec tool

Project description

photorec-sorter

A tool to sort/organize files recovered by the PhotoRec tool

This fork is maintained independently by RecRanger.

Description

PhotoRec does a great job when recovering deleted files. But the result is a huge, unsorted, unnamed amount of files. Especially for external hard drives serving as backup of all the personal data, sorting them is an endless job.

This program helps you sorting your files. It does the following steps:

  1. Files are copied to folders for each file type.
  2. Using exif data, .jpg files are distinguished by the year (and optionally by month) captured, and by the event

We define an "event" as a time span during them photos are taken. It has a delta of 4 days without a photo to another event. If no date from the past can be detected, these jpgs are put into one folder to be sorted manually.

Installation and Usage

Install this project:

uv tool install photorec_sorter

Run this project with either of the following:

photorec_sorter "path_to_files_recovered_by_PhotoRec" "destination_folder"

This copies the recovered files to their file type folder in the destination directory. The recovered files are not modified. If a file already exists in the destination directory, it is skipped. This means that the program can be interrupted with Ctrl+C and then continued at a later point by running it again.

The first output of the program is the number of files to copy. To count them might take some minutes depending on the amount of recovered files. Afterwards, you get some feedback on the processed files.

Arguments

For an overview of all arguments, run with the -h option: photorec_sorter -h.

usage: photorec_sorter [-h] [-n MAX_PER_DIR] [-m] [-k] [-d MIN_EVENT_DELTA] [-j] src dest

Sort files recovered by PhotoRec. The input files are first copied to the destination, sorted by file type. Then, JPG files are sorted based on creation
year (and optionally month). Finally, any directories containing more than a maximum number of files are accordingly split into separate directories."

positional arguments:
  src                   source directory with files recovered by PhotoRec
  dest                  destination directory to write sorted files to

options:
  -h, --help            show this help message and exit
  -n MAX_PER_DIR, --max-per-dir MAX_PER_DIR
                        maximum number of files per directory (default: 500)
  -m, --split-months    split JPEG files not only by year but by month as well (default: False)
  -k, --keep_filename   keeps the original filenames when copying (default: False)
  -d MIN_EVENT_DELTA, --min-event-delta MIN_EVENT_DELTA
                        minimum delta in days between two days (default: 4)
  -j, --enable_datetime_filename
                        sets the filename to the exif date and time if possible - otherwise keep the original filename (default: False)

Max Files per Folder

All directories contain a maximum of 500 files by default. If there are more for a file type, numbered subdirectories are created. If you want another file-limit, e.g. 1000, pass that number with the -n flag.

photorec_sorter "path_to_files_recovered_by_PhotoRec" "destination_folder" -n1000

Folder for Each Month

By default, photorec-sorter sorts your photos by year:

destination
|- 2015
    |- 1.jpg
    |- 2.jpg
    |- ...
|- 2016
    |- ...

Sometimes, you might want to sort each year by month:

photorec_sorter "path_to_files_recovered_by_PhotoRec" "destination_folder" -m

Now, the destination structure will be:

destination
|- 2015
    |- 1
      |- 1.jpg
      |- 2.jpg
    |- 2
      |- 3.jpg
      |- 4.jpg
    |- ...
|- 2016
    |- ...

Keep Original Filenames

Use the -k parameter to keep the original filenames (as recovered):

photorec_sorter "path_to_files_recovered_by_PhotoRec" "destination_folder" -k

Adjust Max Event Duration

For the case you want to reduce or increase the time span between events, simply use the parameter -d. The default is 4 days. To use 10 days, run:

photorec_sorter "path_to_files_recovered_by_PhotoRec" "destination_folder" -d10

Rename .jpg Files with EXIF Date/Time

If the original jpg image files were named by <Date>_<Time> it might be useful to rename the recovered files in the same way. This can be done by adding the -j flag.

photorec_sorter "path_to_files_recovered_by_PhotoRec" "destination_folder" -j

If no EXIF data can be retrieved, the original filename is kept.

In case there are two or more files with the same EXIF data, the filename is extended by an index to avoid overwriting files.

The result will look like:

20210121_134407.jpg
20210122_145205.jpg
20210122_145205(1).jpg
20210122_145205(2).jpg
20210122_145813.jpg
20210122_153155.jpg

Contributing

Please open GitHub Issues/Pull Requests to help improve this project.

Acknowledgements

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

photorec_sorter-0.2.2.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

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

photorec_sorter-0.2.2-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file photorec_sorter-0.2.2.tar.gz.

File metadata

  • Download URL: photorec_sorter-0.2.2.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.5

File hashes

Hashes for photorec_sorter-0.2.2.tar.gz
Algorithm Hash digest
SHA256 7655b099b4ebdbc9e18708bebb6fb679fea690a1723b7c8477da86408c29b264
MD5 b4d24546f40b2a65c77751ce8689c7b5
BLAKE2b-256 82af26b664ec807e3b9c86d64a3ef07e5727922003605288236f8960efe87724

See more details on using hashes here.

File details

Details for the file photorec_sorter-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for photorec_sorter-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a61c59146b47eebd1d048e6c05f9003ed19d818991b96a1d9f4ea953e7f83d1
MD5 9915f60a4e918d40d960b9d9801b097a
BLAKE2b-256 9752b9fe16f51b12e46d7d6b3adf795e4509c9ae5c00138b0158d62bf1ed375d

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