#!/usr/bin/python24 """This app searches through a folder containing files recovered when an fsck found errors on the hard drive and put some files into a lost+found folder. Since there are thousands of files in the folder, I need an easy way to sort them so I can make some decisions about whether I need to keep them or not. This app can find all mbox-type mail files, .png picture files, and anything else. """ import os, os.path, string, shutil, sys, re try: import Tkinter, Pmw except ImportError: print "can't find Tkinter files" #user whose files we want to check user = "stewart" #debug flag dbg=0 print "Starting up.." #get user's home home = os.environ.get('HOME',None) #if root is running this script, force the answer if (home == '/root') or (home is None): home = "/home/%s" % user if dbg: print "%s is running this script" % home #where are the files to investigate? #workdir = os.path.join(home,'.thunderbird','default','d8j853iq.slt','Mail','Local Folders','Messages') workdir = os.path.join(home,'lost+found') os.chdir(workdir) #create a dictionary to deal with all of the types of files we will try to find and process fileDict = {} """elements in fileDict have the following properties: label - label for this type of file (this is the key) destdir - the subdirectory where files of this type will be placed counter - counter for how many files of this type we've found extend - filename extension to add to files of this type (or None) check - check-string that will identify this type """ fileDict["mail1"] = ['mail',0,None,'Return-Path'] fileDict["mail2"] = ['mail',0,None,'Return-path'] fileDict["mail3"] = ['mail',0,None,'From '] fileDict["python"] = ['python',0,'.py','import '] fileDict["xml"] = ['xml',0,'.xml','