-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (31 loc) · 872 Bytes
/
main.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
33
34
35
36
37
38
import sys
from os import *
from filecmp import *
all_files = sorted(listdir())
this_file = path.basename(sys.argv[0])
all_files.remove(this_file)
dont_delete = [this_file]
for i in all_files:
duplicate = False
for j in dont_delete:
if cmp(i,j):
duplicate = True
break
if not duplicate:
dont_delete.append(i)
delete_files = list(set(all_files) - set(dont_delete))
length = len(delete_files)
if length == 0:
print("No duplicate files")
system("pause")
sys.exit()
elif length == 1:
print("Duplicate file: "+delete_files[0]+"\nAre you sure to delete it?")
else:
print("Duplicate files: "+", ".join(delete_files)+"\nAre you sure to delete them?")
answer = input().lower()
if answer in {"yes","y","si","ja","da",""}:
for i in delete_files:
remove(i)
print("√ success!")
system("pause")