in reply to Re^3: stitch together text file recovered by photorec/testdisk?
in thread stitch together text file recovered by photorec/testdisk?

idea: start with shortest smallest files (1-3k, half the files), see which bigger files they match
  • Comment on Re^4: stitch together text file recovered by photorec/testdisk?

Replies are listed 'Best First'.
Re^5: stitch together text file recovered by photorec/testdisk?
by Anonymous Monk on Sep 11, 2018 at 02:53 UTC
    Hmm, starting with half yielded only ("copies", 74), checking all files against all files yields ("copies", 847) leaving only 1200 files / 6.54MB , thats less than the nulls 8MB, hmmm, have I eliminated data or actually lost it?
    ... use constant NAME => 0; use constant SIZE => 1; use constant VALU => 2; use constant COPY => 3; my @files = sort { $$a[SIZE()] <=> $$b[SIZE()] } map { [ $_, path($_)->stat->size, path($_)->slurp_raw, ]; } glob 'myfinalmaybeit/*'; my @half = @files; my $copies=0; for my $half ( @half ){ for my $file ( @files ){ if( $half != $file ## cause self will match self and $file->[VALU] =~ m{\Q$half->[2]\E} ){ $copies++; push @{ $half->[COPY] }, $file->[NAME]; } } } @files = sort { $$a[NAME()] cmp $$b[NAME()] } @files; $_->[VALU]=undef for @half, @files; dd( @files ); dd( 'copies', $copies ); path('myfinalmaybeit1k')->mkpath; for my $file ( @files ){ my $ref = $file->[ 3 ] ; if( not defined $ref or not @{ $ref } ){ path( $file->[0] )->copy('myfinalmaybeit1k/'); } } __END__