Skip to content

de-jcup/photorec-directory-beautifier

Repository files navigation

photorec directory beautifier

Photorec directory beautifier

Why this tool was created

I had a crashed hard disk and was forced to recover data because many photos and movies were contained without any backup.

My steps to recover my data:

  • Having no longer any access to hard drive I thought the PCB controller could be the problem

  • So I bought a second hand hard disk having same hardware specification as my crashed device

  • Replaced defect PCB controller

  • Booted with a LIVE Linux CD …​

  • Was able to access my hard drive again - but with errors and no file system

  • Started a full dump / restore of my hard disk with ddrescue:
    ddrescue /dev/sdb ./full-sdb-backup.img ./full-sdb-rescue.log

  • After some time even the "new" PCB controller crashed, but at least an image was available with some data.

  • I used photorec, which is part of testdisk suite, to restore photos from former created image.
    (Simply call photorec on command line)

I was able to recover a big amount of data - not all, but most data. Thanx a lot to all people involved developing formerly mentioned tools!

Unfortunetely the resulting file structure contains all recovered files in a random structure and also random file names. Only the modification time stamp was recovered as well:

photoRecOutputDir/
  recup_dir.1/
         f0225128.jpg
         f0236000.jpg
         f0321233.doc
         f0423351.exe
         ...etc.
  recup_dir.2/
  	     ...etc.
  recup_dir.63
         ...etc.

I was only interested in some specific files - mostly in JPEG. Also sorting all these files manually (>60.000 files) was no option. So I wrote this software.

License

To keep this simple this software is MIT license.

Build

Just execute ./gradlew fatJar

This will build pdb.jar inside build/libs which contains all dependencies.

Usage

java -jar pdb.jar -s ${photoRecOutputDir} -t ${pdbTargetDir}

Output structure

It simply tries to get origin creation time from files (JPEG meta information). If not possible the "last modified" file time stamp is used as a fallback. It also makes top level sub directories which have upppercased filending name, so garbage can be easily destroyed by a folder delete.

File names are in format yyyy-MM-dd_HH-mm-ss with origin file name ending.

Here an example output:

pdbTargetDir/
        JPEG/
           2019/
               01/
                 2019-01-01_13-12-01.jpg
                 2019-01-11_14-03-21.jpg
                 ...etc..
               12/
                 2019-12-01_13-12-01.jpg
                 2019-12-01_13-13-21.jpg
                 ...etc...

           2020/
               ...etc...

        EXE/
           2008/
                05/
                  2008-05-01_23-12-10.exe
                  ..etc..
                ..etc..
           ..etc..
        DOC
           ..etc..
        ...etc..

About

A simple tool which creates a sorted filestructure after recovering images with ddrescue and photorec

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages