Skip to content
Browse files

Find files that differ between two directories --

even if they've been moved to different places in the
directory structure.
  • Loading branch information...
1 parent c2c55b3 commit 3f88f5c33f0a0194baec3e6535768e674f189541 @akkana committed Mar 22, 2013
Showing with 25 additions and 0 deletions.
  1. +25 −0 diffiles.py
View
25 diffiles.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+# find filenames in dir1 that are NOT in dir2.
+# It need not be in the same place -- this is useful instead of diff -r
+# when you've reordered a file tree.
+
+import sys, os
+
+# Get the set of files in dir1:
+files1 = set()
+for root, dirs, files in os.walk(sys.argv[1]) :
+ for f in files :
+ files1.add(f)
+
+# Get the set of files in dir2:
+files2 = set()
+for root, dirs, files in os.walk(sys.argv[2]) :
+ for f in files :
+ files2.add(f)
+
+print "In", sys.argv[1], "but not", sys.argv[2], ":"
+print '\n'.join(files1 - files2)
+print
+print "In", sys.argv[2], "but not", sys.argv[1], ":"
+print '\n'.join(files2 - files1)

0 comments on commit 3f88f5c

Please sign in to comment.
Something went wrong with that request. Please try again.