-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfolder_comparison.py
More file actions
45 lines (32 loc) · 1.2 KB
/
folder_comparison.py
File metadata and controls
45 lines (32 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
__author__ = 'Peter Hevesi'
from os import listdir, walk
from os.path import isfile, isdir, join
source = input("\n\tChoose source directory: ").strip()
dest = input("\tChoose destination directory: ").strip()
print( "\tComparing structure of ", source," and ", dest )
source_list = []
dest_list = []
def scan_dir( path, itemlist, parent="" ):
current_dir_items = listdir(path)
for item in current_dir_items:
if isdir(join(path, item)):
itemlist = scan_dir( join(path, item), itemlist, join(parent, item))
else:
itemlist.append( join(parent, item))
return itemlist
source_list = scan_dir( source, source_list)
dest_list = scan_dir( dest, dest_list)
print("\t-------- Missing in destination folder : --------")
any_diff = False
for f in source_list:
if f not in dest_list:
print('\t', f, " is missing in destination.")
any_diff = True
print("\n\n\t-------- Missing in source folder : --------")
for f in dest_list:
if f not in source_list:
print('\t', f, " is missing in source.")
any_diff = True
if not any_diff:
print("\tNo difference between source and destination.")
print("\t--------------------------------")