Merge branch 'master' into add-renaming-jpgs

This commit is contained in:
Lukas Hahmann 2022-08-20 18:19:51 +02:00 committed by GitHub
commit a223b9f7da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 16 deletions

View File

@ -1,35 +1,34 @@
# Sort files recoverd by Photorec
# Sort files recovered by Photorec
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 sPRF helps you sorting your files. First of all, the **files are copied to own folders for each file type**. Second, **jpgs are distinguished by the year, and optionally by month as well** when they have been taken **and by the event**. We thereby 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
First install the package [exifread](https://pypi.python.org/pypi/ExifRead):
```pip install exifread```
`pip install exifread`
## Run the sorter
Then run the sorter:
```python recovery.py <path to files recovered by Photorec> <destination>```
`python recovery.py <path to files recovered by Photorec> <destination>`
This copies the recovered file 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. Hence you can interrupt the process with Ctrl+C and continue afterwards.
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 programm is the number of files to copy. To count them might take some minutes depending on the amount of recovered files. Afterwareds you get some feedback on the processed files.
### Parameters
For an overview of all arguments, run with the `-h` option: ```python recovery.py -h```.
For an overview of all arguments, run with the `-h` option: `python recovery.py -h`.
#### Max numbers of files per folder
All directories contain maximum 500 files. If one contains more, numbered subdirectories are created. If you want another file-limit, e.g. 1000, just put that number as third parameter to the execution of the programm:
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 as the third parameter when running the program:
```python recovery.py <path to files recovered by Photorec> <destination> -n1000```
`python recovery.py <path to files recovered by Photorec> <destination> -n1000`
#### Folder for each month
@ -47,7 +46,7 @@ destination
Sometimes you might want to sort each year by month:
```python recovery.py <path to files recovered by Photorec> <destination> -m```
`python recovery.py <path to files recovered by Photorec> <destination> -m`
Now you get:
@ -69,16 +68,14 @@ destination
Use the -k parameter to keep the original filenames:
```python recovery.py <path to files recovered by Photorec> <destination> -k```
`python recovery.py <path to files recovered by Photorec> <destination> -k`
#### Adjust event distance
For the case you want to reduce or increase the timespan between events, simply use the parameter -d. The default is 4:
```python recovery.py <path to files recovered by Photorec> <destination> -d10```
#### Rename jpg-files with ```<Date>_<Time>``` from EXIF data if possible
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 parameter -j.
@ -98,4 +95,3 @@ The result will look like:
20210122_145813.jpg
20210122_153155.jpg
```

View File

@ -108,7 +108,10 @@ for root, dirs, files in os.walk(source, topdown=False):
extension = os.path.splitext(file)[1][1:].upper()
sourcePath = os.path.join(root, file)
destinationDirectory = os.path.join(destination, extension)
if extension:
destinationDirectory = os.path.join(destination, extension)
else:
destinationDirectory = os.path.join(destination, "_NO_EXTENSION")
if not os.path.exists(destinationDirectory):
os.mkdir(destinationDirectory)
@ -133,7 +136,10 @@ for root, dirs, files in os.walk(source, topdown=False):
fileName = file
else:
fileName = str(fileCounter) + "." + extension.lower()
if extension:
fileName = str(fileCounter) + "." + extension.lower()
else:
fileName = str(fileCounter)
destinationFile = os.path.join(destinationDirectory, fileName)
if not os.path.exists(destinationFile):