Enhanced "After Using PhotoRec" script
Posted: 03 Jan 2018, 00:35
Hi all,
This is my first post in this forum, so please be tolerant if I do formal mistakes.
In the wiki on https://www.cgsecurity.org/wiki/After_Using_PhotoRec there is a script for recovering the original file names from a Canon camera. It does not work for my files, recovered from a Canon A2200 SD-card on my Ubuntu machine, because the respective tag values do not begin solely with "100". Also the path for jhead matched bad and a leading Shebang may be helpful.
I have enhanced the script which now works fine:
Also a hint may be useful, that jhead must first be installed, e.g. on Ubuntu with:
Kind regards
Ulf
This is my first post in this forum, so please be tolerant if I do formal mistakes.
In the wiki on https://www.cgsecurity.org/wiki/After_Using_PhotoRec there is a script for recovering the original file names from a Canon camera. It does not work for my files, recovered from a Canon A2200 SD-card on my Ubuntu machine, because the respective tag values do not begin solely with "100". Also the path for jhead matched bad and a leading Shebang may be helpful.
I have enhanced the script which now works fine:
Code: Select all
#!/usr/bin/perl -w
$working_dir = '.';
$jhead_bin = '/usr/bin/jhead';
@recovered_files = `ls $working_dir`;
foreach $file (@recovered_files) {
chomp $file;
@exif = `$jhead_bin -v $working_dir/$file`;
foreach $line (@exif) {
if ($line =~ /Canon maker tag 0008 Value = [1-9]\d\d(\d{1,8})$/) {
system("mv $working_dir/$file $working_dir/IMG_$1.JPG");
print "IMG_$1.JPG from $file\n";
last;
}
}
}
Code: Select all
sudo apt install jhead
Ulf