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
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:
- Files are copied to folders for each file type.
- 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:
python3 -m pip install photorec_sorter
Run this project with either of the following:
python3 -m photorec_sorter "path_to_files_recovered_by_PhotoRec" "destination_folder"
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: python3 -m 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.
python3 -m 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:
python3 -m 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):
python3 -m 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:
python3 -m 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.
python3 -m 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
- Thanks to Christophe Grenier at CGSecurity for creating TestDisk/PhotoRec.
- Thanks to ChrisMagnuson for the original creation of sort-PhotorecRecoveredFiles.
- Thanks to tfrdidi for
their fork of sort-PhotorecRecoveredFiles,
upon which this
photorec-sorter
project is based.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file photorec_sorter-0.1.1.tar.gz
.
File metadata
- Download URL: photorec_sorter-0.1.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cad2b358a0afd54a6fef407d34fa1a5c64b13e5dacd67b59adb6230bd24385e7 |
|
MD5 | 10556da737e46a8cadb331f73fb9d106 |
|
BLAKE2b-256 | 35553eb70aa6cce6d4108f195889e11b512cc3450c9b5dd093ba483ddc361fc4 |
File details
Details for the file photorec_sorter-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: photorec_sorter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43cbe3335ff587862be2e08c7c4c85d95117089a7f9345d2f3bbbf8e11eeab63 |
|
MD5 | 3ce09821c45093ece46e4d4208ac6198 |
|
BLAKE2b-256 | 14e484698a60c8815623f457796b409992d15d40a47a3423a6766585f5d83ee7 |