-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfindDuplicateFiles.py
32 lines (20 loc) · 1.03 KB
/
findDuplicateFiles.py
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
import os
import shutil
# src_folder = 'C:/Users/Tommy/Desktop/Done'
# dst_folder = 'C:/Users/Tommy/Desktop/New/abb'
src_folder = 'E:/UofA/Thesis/Code/TrackingFramework/C++/MTF/log/success_rates'
dst_folder = 'E:/UofA/Thesis/Code/TrackingFramework/C++/MTF/log/success_rates/TMT'
duplicate_folder = 'duplicates'
src_files = [f for f in os.listdir(src_folder) if os.path.isfile(os.path.join(src_folder, f))]
dst_files = [f for f in os.listdir(dst_folder) if os.path.isfile(os.path.join(dst_folder, f))]
print 'Found {:d} source files'.format(len(src_files))
print 'Found {:d} test files'.format(len(dst_files))
duplicate_files = set(src_files) & set(dst_files)
if len(duplicate_files) > 0:
print 'Found {:d} duplicate files:\n'.format(len(duplicate_files)), duplicate_files
else:
print 'Found no duplicate files'
if not os.path.exists(duplicate_folder):
os.mkdir(duplicate_folder)
for file in duplicate_files:
shutil.move(os.path.join(dst_folder, file), os.path.join(duplicate_folder, file))