Problem with file cleaning process?
<p>I am working on very large file system. My task is to clean the system with some given parameters. Below program fragment can give a idea.</p>

<pre><code>import DirectoryWalker


extentions_to_delete = list([".rar",".doc",".URL",".js",".EXE",".mht",".css",".txt", ".cache", ".xml"])
extentions_to_copy = list([".jpg",".BMP",".GIF",".jpeg",".gif",".bmp",".png",".JPG"])

dw = DirectoryWalker.DirectoryWalker("/media/08247451247443AA/home/crap/")

def copy_advice(key, files):
    for ext in extentions_to_copy:
        if(ext == key):
            print str(len(files)) + " Files of type " + key + " should be coppied to the target folder."
            for file in files:
                copy_to = "/media/08247451247443AA/home/crap-pics/"

                moved = dw.move_file_to(file, copy_to, True)
                if not moved:
                    print file + " : not moved"

walks = dw.get_all_file_types()


for key in DirectoryWalker.Walk.store.keys():
    files = DirectoryWalker.Walk.store[key]

    copy_advice(key, files)
</code></pre>

<p>In the <code>DirectoryWalker</code> following code is written. Walk is a simple class which have a <code>store</code> object.</p>

<pre><code>def get_all_file_types(self):

    extentions = []

    for dirpath,dirnames,filenames in os.walk(self.dir_name):
        for file in filenames:
            extentions.append(Walk(dirpath +"/"+ file))

    return extentions            

def move_file_to(self, file_path, copy_to, rename_if_exists= False):
        file_name = os.path.split(file_path)[1]

        target_file_name = copy_to + file_name;

        coppied = False

        if not os.path.isfile(target_file_name):
            coppied = True
            try:
                os.rename(file_path, target_file_name)
            except OSError:
                coppied = False
                print "Oops! Unable to rename : " + file_path + " to target : " + target_file_name

        if rename_if_exists:
            coppied = True
            file_name = "new_"+ file_name
            try:
                os.rename(file_path, target_file_name)  
            except OSError:
                coppied = False
                print "Oops! Unable to rename : " + file_path + " to target : " + target_file_name        

        return coppied
</code></pre>

<p>The <code>Walk</code> class</p>

<pre><code>class Walk:

    store = dict([])

    def __init__(self, filename):

        self.file_ext = os.path.splitext(filename)[-1]
        self.file_name = filename

        if not (Walk.store.has_key(self.file_ext)):
            Walk.store[self.file_ext] = list() 

        Walk.store[self.file_ext].append(self.file_name)
</code></pre>

<p>But when program executed, it only moves almost 10400 files. But manual calculation suggest, there should be 13400 files in the file system. Please let me know, what I am doing wrong?</p>

<p>Update Solutions</p>

<p>After a careful investigations, I come out with result that there are many ambiguous file names in the target file system and those files were missing. </p>
