Created
January 30, 2012 08:13
-
-
Save lantius/1703291 to your computer and use it in GitHub Desktop.
perl script for recovering images from a CF card
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
print "Starting CompactFlash card recovery\n"; | |
$argsLen = $#ARGV + 1; | |
if ($argsLen < 2) { | |
print "Error:\nIncorrect usage of file, please supply 2 arguments\n."; | |
print "./recover.pl \n"; | |
print " - Path to the dumpfile \n"; | |
print " - Destination for recovered files\n"; | |
print "./recover.pl ~/dumpfile ~/recovered\n"; | |
exit; | |
} | |
open (DUMPFILE, $ARGV[0]); | |
my $line; | |
$line = "\xff\xd8\xff\xe1"; | |
$i = 0; | |
while (<DUMPFILE>) { | |
$temp = $_; | |
my @files = split(/\xff\xd8\xff\xe1/, $temp); | |
$line = $line.$files[0]; | |
for($j = 1; $j < @files; $j++) { | |
open (NEWFILE, "> " . $ARGV[1] . "/" . $i . ".jpeg") or | |
die "Error cannot create new file\n"; | |
print NEWFILE $line; | |
close(NEWFILE); | |
$line = "\xff\xd8\xff\xe1".$files[$j]; | |
$i++; | |
} | |
} | |
close(DUMPFILE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment