![]() |
VOOZH | about |
Es kann schwer sein, die unter PhotoRec wiederhergestellten Dateien zu sortieren . Du kannst hier einige Ideen finden, die dir in diesem Prozess helfen können.
Mit diesem Python Skript kann man die Dateien nach der Dateierweiterung sortieren:
import os
import os.path
import shutil
while True:
source = raw_input('Enter the source directory\n')
if os.path.exists(source): break
else: print 'The directory you have entered does not exist'
while True:
destination = raw_input('Enter the destination directory\n')
if os.path.exists(destination): break
else: print 'The directory you have entered does not exist'
for root, dirs, files in os.walk(source, topdown=False):
for files2 in files:
extension = os.path.splitext(os.path.join(root,files2))[1][1:]
if os.path.exists(os.path.join(destination,extension)):
shutil.copy(os.path.join(root,files2), os.path.join(destination,extension))
else:
os.mkdir(os.path.join(destination,extension))
shutil.copy(os.path.join(root,files2), os.path.join(destination,extension))
#!/usr/bin/perl -w
# read optional working directory from the command line:
$dir = (@ARGV > 0) ? $ARGV[0] : '.';
$dir =~ s/\/*$//; # truncate trailing '/'s
foreach $file (glob "$dir/*") {
chomp $file;
open(EXIF, '-|', 'jhead', '-v', $file) or die "Not found jhead $!";
if (defined(<EXIF>)) {
foreach $line (<EXIF>) {
if ($line =~ /Canon maker tag 0008 Value = [1-9]\d\d(\d{1,8})$/) {
rename($file, "$dir/IMG_$1.JPG");
print "$dir/IMG_$1.JPG from $file\n";
last;
}
}
close EXIF or die "EXIF: $! $?";
}
}
Stelle zusätzlich den originalen Ordnerbaum wieder her: --UlfZibis 16:10, 17 January 2018 (CET)
#!/usr/bin/perl -w
# read optional working directory from the command line:
$dir = (@ARGV > 0) ? $ARGV[0] : '.';
$dir =~ s/\/*$//; # truncate trailing '/'s
foreach $file (glob "$dir/*") {
chomp $file;
open(EXIF, '-|', 'jhead', '-v', $file) or die "Not found jhead $!";
if (defined(<EXIF>)) {
$folder_no = '000';
$picture_no = '0000';
$date = '0000';
foreach $line (<EXIF>) {
if ($line =~ /Canon maker tag 0008 Value = ([1-9]\d\d)(\d{1,8})$/) {
$folder_no = $1;
$picture_no = $2;
}
if ($line =~ /Time\s*:\s*\d{4}:(\d\d):(\d\d)\s[\d:]{8}$/) {
# $date = "$1$2";
$date = "$2$1"; # if camera language setting = german
last;
}
}
print "$dir/$folder_no\_$date/IMG_$picture_no.JPG from $file\n";
mkdir("$dir/$folder_no\_$date");
rename($file, "$dir/$folder_no\_$date/IMG_$picture_no.JPG");
close EXIF or die "EXIF: $! $?";
}
}
Oder nutze dieses Skript zum Auflisten aller Verzeichnisse, Suchen von Dateien bestimmter Größe, und speichere diese in einem Datums-basierten Verzeichnis:
#!/usr/bin/perl -w
$working_dir = '/home/myhome/';
$result_dir = '/home/myhome/photos/'
$jhead_bin = '/usr/bin/jhead';
@rec_dirs = `ls ${working_dir} | grep recup_dir`;
foreach $recup_dir (@rec_dirs) {
print "Scanning ${recup_dir}...";
chomp $recup_dir;
@photos_in_recup = `find ${working_dir}${recup_dir}/*jpg -type f -size +800k`;
foreach $photo_file (@photos_in_recup) {
chomp $photo_file;
#print "IMG $photo_file in $recup_dir\n";
@exif = `$jhead_bin -v $photo_file`;
#print "$jhead_bin -v $photo_file\n";
foreach $line (@exif) {
if ($line =~ /Time\s*:\s*([0-9]{4}):([0-9]{2}):([0-9]{2})\s[0-9:]{8}$/) {
print "IMG $photo_file $1-$2-$3\n";
system("mkdir ${result_dir}$1-$2-$3");
# system("mv $photo_file $result_dir/$1-$2-$3/");
last;
}
}
}
}
@echo off for %%f in (*.jpg) do call :process %%f goto :eof :process for /f "usebackq delims=- tokens=1,2" %%a in (`exiftool -p ^"^$FileNumber^" %1`) do set gnum=%%a&set fnum=%%b if "%gnum%"=="" goto :eof if "%fnum%"=="" goto :eof if not exist %gnum%CANON ( echo Creating directory %gnum%CANON mkdir %gnum%CANON ) echo Moving %1 to %gnum%CANON\_mg_%fnum%.jpg ren %1 _mg_%fnum%.jpg>NUL move _mg_%fnum%.jpg %gnum%CANON>NUL goto :eof
for file in recup_dir*/*; do convert $file $file; done
In diesem Beispiel überprüfen wir die ersten 80k von recup_dir*/*.sib
for file in recup_dir.*/*.sib; do MD5=`dd count=20 bs=4k if="$file" 2> /dev/null|md5sum`; echo "$MD5 $file"; done|sort 1a07198de3486ff2ecab7859612fe7ba - Box Clever.sib 33105f4a7997b2e2681e404b3ac895f2 - Random, Matching - 2 bars.sib 376e0c53e78e56ba6f2858d9680f8c6b - 01aIdentifyCommonInst.sib b0b40a516a1e26660748a0a09cdf3207 - 01ArticulationFlashcards.sib
Wenn jede Checksumme einzigartig ist gibt es keine Duplikate.
@echo off SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION SET FILELIST= FOR %%i IN (*) DO ( FOR %%j IN (!FILELIST!) DO ( IF %%~zi EQU %%~zj ( fc /b "%%~i" "%%~j">NUL && echo "%%~i" = "%%~j" ) ) SET FILELIST=!FILELIST! "%%~i" ) ENDLOCAL