ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/CompareDirByHash.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 1017 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 """
2     CompareDirByHash
3    
4     This program will compare the files, in to exact top level directories, by their hash values.
5    
6     Created by
7     Emanuel Borges
8     07.12.2008
9    
10     """
11    
12     from NinoGenTools import HashFileContents
13     import os
14    
15     def CompareHashValues(args,dirName, fileNames):
16     outputFile = args[0]
17     hshFile = args[3]
18     dirName2 = dirName.replace(args[2], args[1])
19     for file in fileNames:
20     if os.path.isfile(dirName + "\\" + file):
21     hshVal1 = hshFile.HashFile(dirName + "\\" + file)
22     hshVal2 = hshFile.HashFile(dirName2 + "\\" + file)
23     if hshVal1 == hshVal2:
24     pass
25     else:
26     outputFile.write(dirName + "\\" + file +"\n")
27    
28    
29     if __name__ == "__main__":
30     hshFile = HashFileContents('md5')
31     startDir = r"g:\dev"
32     mirrorDir = r"I:\Documents\Dev"
33     differFile = open(r"c:\test_dir\Hash_differs.txt",'w')
34     args = [differFile,mirrorDir, startDir,hshFile]
35     os.path.walk(startDir,CompareHashValues,args)