We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bca9799 commit a28393bCopy full SHA for a28393b
moumoubaimifan/remove/removeFile.py
@@ -0,0 +1,29 @@
1
+import os
2
+import zlib
3
+import glob
4
+
5
+def scanning_floder(glob_path):
6
+ crc32Dict = {}
7
+ for fname in glob.glob(glob_path, recursive=True):
8
+ if os.path.isfile(fname):
9
+ crc = crc32(fname)
10
+ if crc in crc32Dict:
11
+ print('已经存在文件:' + crc32Dict.get(crc))
12
+ print('重复文件:' + fname)
13
+ print('删除文件:' + fname)
14
+ os.remove(fname)
15
+ print('')
16
+ else:
17
+ crc32Dict[crc] = fname
18
19
+def crc32(file_path):
20
+ with open(file_path, 'rb') as f:
21
+ hash = 0
22
+ while True:
23
+ s = f.read(1024)
24
+ if not s:
25
+ break
26
+ hash = zlib.crc32(s, hash)
27
+ return "%08X" % (hash & 0xFFFFFFFF)
28
29
+scanning_floder("D:\personal\新建文件夹/**/*")
0 commit comments