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.0.tar.gz (20.7 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.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for photorec_sorter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0b504384f017f97d83a2e435288ede03c2c886bbf7ae1e196821de0fb63eaf90
MD5 c2d6f826a70aae65f6ebf18c1cf88007
BLAKE2b-256 41bf68bd71dcffbc8c114bd559b939543de4a8ad08e4554ed19734f26cc05fd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for photorec_sorter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb668fb081a3a07e8e9de644840876d24ab920a9f12a310ea8f9c95500871dd9
MD5 d201a64da3efa124c982f2caee1b66d0
BLAKE2b-256 71597a3acffff3031f883b085081214175855d77fa18ab561ab952225cea072f

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