How do I salvage files from the lost+found folder?

1

1

Well, I screwed up my external hard drive and now everything is in the lost+found folder. I can barely look through it because there is several tens of thousands of files (buncha inode things) and a lot of empty folders. My question is, is there anyway I can get straight to the video, audio, and image files that are strewn across these folders?

RPG Master

Posted 2010-03-01T04:40:10.697

Reputation: 148

Answers

1

I am not sure how (or even if) you could recover the original location of all the files. But at the very least you could start sorting them based on the content.

For starters, rox (aka Rox-Filer) is not dependent on file name extensions to know file type (it uses the actual file contents), so if you want a point and click browser that will open the files for inspection with the right app regardless of filename, I would try rox if Nautilus isn't working. If the problem with Nautilus is that the size of the directory is making it hard to use, in my experience rox works pretty well with huge directory listings as well (just be sure preview is turned off for images and video).

On the command line, the file command should tell you what kind of file each of the files is (I think that is the utility that rox is using internally). If you have some comfort with the command line you could even do some sorting via script (ie. move movies to one directory, audio files to another, etc.).

Edit

Here is something that may be helpful, I tested this on some copies of various files without the three letter filename extensions, so I know it works. It should be easy to check the output of file for various items to add clauses (and of course you will want to change the destination directories for all of this):

    #!/bin/sh

    mkdir -p ~/test-imgs;
    mkdir -p ~/test-vids;
    mkdir -p ~/test-music;

    for i in $*
    do
        ( [ -n "`file $i | grep image`" ] && mv $i ~/test-imgs )  ||
        ( [ -n "`file $i | grep video`" ] && mv $i ~/test-vids )  ||
        ( [ -n "`file $i | grep Audio`" ] && mv $i ~/test-music ) ||
        ( [ -n "`file $i | grep III`" ]   && mv $i ~/test-music )
    done

Justin Smith

Posted 2010-03-01T04:40:10.697

Reputation: 3 746

Thanks for the help. Rox hangs for about 3 minutes and then works like a charm :)

After looking around, all the files that are directly in the lost+found folder are nothing but "socket", "tunnel", and other file system stuff. So now I guess I got to go through all those folders... :(

Would that script go through those folders for me? – RPG Master – 2010-03-02T17:48:16.707

The way it works is it moves any files you provide as arguments to one of the three directories, depending on file type, so you would invoke it as so (after saving it as filesorter.sh and set as executable): "./filesorter.sh *" would run it on every file in the current directory. If you really want to automatically sort the contents of the folders, you could change the script to "mkdir -p ./..." for each of the three folders instead of "mkdir -p ~/...", in order to preserve folder structure. You may want something using "find" that would recursively sort out each subdir of lost+found ... – Justin Smith – 2010-03-03T01:21:04.950