LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 11-11-2012, 04:55 AM   #1
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 328

Rep: Reputation: 7
Sorting Photorec results


Hi all,

Is there a quick and easy way of sorting the results of files recovered by Photorec? I'm only after a few types of files from the 30+ folders of 500+ files per folder? Ideally I'd like each file type in a different folder.

Is that fairly simple to achieve? I'm hoping a bash script somehow?

Thanks
 
Old 11-11-2012, 05:24 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
For those of us that don't have Photorec but may be able to help, it would be helpful if you posted a short illustrative sample of the Photorec output you want to sort -- or a full output somewhere like pastebin
 
Old 11-11-2012, 05:36 AM   #3
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 328

Original Poster
Rep: Reputation: 7
Hi, a sample should get the point of how it sorts it.

So photorec uses some sort of black magic to recover 'deleted' files, or in my case a SD Card with no partition table. It recovers them into folder like this:
Code:
$ pwd
/home/user/Photorec

$ ls
recup_dir.1   recup_dir.17  recup_dir.24  recup_dir.31  recup_dir.4
recup_dir.10  recup_dir.18  recup_dir.25  recup_dir.32  recup_dir.5
recup_dir.11  recup_dir.19  recup_dir.26  recup_dir.33  recup_dir.6
recup_dir.12  recup_dir.2   recup_dir.27  recup_dir.34  recup_dir.7
recup_dir.13  recup_dir.20  recup_dir.28  recup_dir.35  recup_dir.8
recup_dir.14  recup_dir.21  recup_dir.29  recup_dir.36  recup_dir.9
recup_dir.15  recup_dir.22  recup_dir.3   recup_dir.37
recup_dir.16  recup_dir.23  recup_dir.30  recup_dir.38
In each of the folders, you have a list of files:

So in recup_dir.38 a short selection of files using "ls" is:
Code:
f21331411.txt  f21357080.txt  f21375205.txt  f21380160.jpg  f23113738.java
f21331416.txt  f21358016.jpg  f21375210.txt  f21380224.jpg  f23113740.java
f21331502.txt  f21358111.txt  f21375215.txt  f21380352.jpg  f23114929.java
f21331584.txt  f21358120.txt  f21375220.txt  f21380480.jpg  f23114930.java
f21331925.txt  f21358154.txt  f21375264.txt  f21380544.jpg  f23114932.java
f21331968.jpg  f21358391.txt  f21375808.txt  f21380608.jpg  f23114933.java
f21332096.jpg  f21358399.txt  f21376003.txt  f21380672.jpg  f23114934.java
f21332160.jpg  f21358774.txt  f21376005.txt  f21380736.jpg  f24059928.ini
f21333300.txt  f21358786.txt  f21376007.txt  f21380864.jpg  t21327872.jpg
f21333303.txt  f21358796.txt  f21376015.txt  f21380928.jpg  t21328832.jpg
That's the smallest directory by 200 items, containing 331.

I hope that clarifies my problem a little bit, apologies if it's a little too simple or not complicated enough. I'm not great with computers so it's hard to know what's common knowledge and what's not, I hope I haven't seemed patronising.
 
Old 11-11-2012, 08:16 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,709
Blog Entries: 54

Rep: Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965
* If you are certain your SD cards contained only image files with certain extensions then I would backup the results and rerun Photorec with only those specific image file filters enabled.
* For sorting see http://www.cgsecurity.org/wiki/After_Using_PhotoRec

Note the script below looks only at the string after the last dot and it will create directories like /home/user/Photorec/txt, /home/user/Photorec/jpg, etc, etc:
Code:
cd /home/user/Photorec
find /home/user/Photorec/recup_dir*/ -type f | while read ITEM; do
 TARGET=${ITEM//*./}; if [ ! -d "/home/user/Photorec/${TARGET}" ]; then
  mkdir "/home/user/Photorec/${TARGET}"; fi
 mv "${ITEM}" "/home/user/Photorec/${TARGET}"
done
 
2 members found this post helpful.
Old 11-14-2012, 05:24 AM   #5
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 328

Original Poster
Rep: Reputation: 7
Fantastic, thank you very much for the link and the script.

Unfortunately, I wasn't 100% sure that my photos would not be saved as .jpg, .JPG, .JPEG etc so that's why I just recovered everything. Now I've reused the card I can't re-photorec it, but they're not sorted into a manageable order.

Thanks again
 
Old 11-14-2012, 07:45 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,709
Blog Entries: 54

Rep: Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965
Quote:
Originally Posted by NotAComputerGuy View Post
Now I've reused the card I can't re-photorec it,
For next time remember to make a bit-by-bit copy of the victim drive. That way you have a backup to work on leaving the original intact.


Quote:
Originally Posted by NotAComputerGuy View Post
but they're not sorted into a manageable order.
Yes, because once deleted there is no longer any order. BTW if your images contain EXIF data you may be able to at least order them according to image creation time:
Code:
cd /home/user/Photorec
find /home/user/Photorec/recup_dir*/ -type f | while read ITEM; do
 file "${ITEM}" 2>&1|egrep -q "(JPEG|JFIF)" && \
  { RES=($(exiftime "${ITEM}" 2>/dev/null)); [ ${#RES[@]} -eq 4 ] && echo "${ITEM} ${RES[2]} ${RES[3]}"; }
done
 
2 members found this post helpful.
Old 11-14-2012, 11:43 AM   #7
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 328

Original Poster
Rep: Reputation: 7
Quote:
Originally Posted by unSpawn View Post
Yes, because once deleted there is no longer any order.
Sorry, that was a typo. Not was mean to read now. I can manage to go through the photos and arrange them properly.

Thanks
 
Old 11-06-2013, 07:09 AM   #8
kishor joshi
Member
 
Registered: Jan 2013
Location: Pune,India
Distribution: Linux Mint16 Cinnamon, 64-bit,Linux Mint 17
Posts: 51
Blog Entries: 1

Rep: Reputation: Disabled
Arranging photos recovered by using Photorec

Quote:
Originally Posted by NotAComputerGuy View Post
Sorry, that was a typo. Not was mean to read now. I can manage to go through the photos and arrange them properly.

Thanks
=====================================================================
While using Photorec there is an option for file types to br recorved.
For recovering photos use JPEG file option and disable all other file types.
With this the size of recup directories (in Home folder) will be manageble and home folder will still have memory left.
Creat a new folder - Name it as Photo-rec.
Open folder of recup_dir-1 as a root.
Copy all files from this folder to newly created folder Photo-rec.
open all the folders recup_dir one after another as a root and copy files to newly created folder Photo-rec.
Now you can delet all recup_dir folders,since all recovered photos are in newly created folder Photo-rec.
Install Shotwell from Synaptic or Software Center.
Open Shotwell.Import photos from Photo-rec.While imporing from folder use copy option.
Shotwell will import and make albums in Picture folder.The albums are created Yearwise,having subfolders monthwise and datewise.Shotwell does not import duplicate photos.
The sorting is done in minutes.
Images from web are sored in a seperate folder havig year as 1997 or1998 (earlier year that of Jpeg images recovered of Camera Photos.
I had recently recovered around 16000 photos.
Shotwell had sorted the photos within 10 minitues.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting photorec output Mark_667 Linux - Software 3 05-25-2012 08:47 AM
Photorec navy80 Linux - Software 1 03-30-2011 11:37 AM
Photorec tommytomato Linux - Software 2 09-28-2010 06:57 AM
problem compiling photorec 6.5 fakie_flip Linux - Software 3 08-15-2006 01:40 AM
block size for photorec fakie_flip Linux - Software 0 08-12-2006 12:01 PM


All times are GMT -5. The time now is 12:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration