删除电脑微信目录下重复文件
import osimport zlib
import time
import re
#递归文件夹
def recursionFolder(path):
filename_regex = re.compile(r'.*\(\d+\)\..*')
crcList=list()
for root,dirs,files in os.walk(path):
for file in files:
print(os.path.join(root,file))
temp = filename_regex.search(file)
if temp != None:
os.remove(os.path.join(root,file))
if os.path.exists((os.path.join(root,file))):
fileCRC=crc32(os.path.join(root,file))
if fileCRC in crcList:
os.remove(os.path.join(root,file))
else:
crcList.append(fileCRC)
#获取文件crc值
def crc32(file_path):
with open(file_path, 'rb') as fh:
hash = 0
while True:
s = fh.read(65536)
if not s:
break
hash = zlib.crc32(s, hash)
return "%08X" % (hash & 0xFFFFFFFF)
recursionFolder("./") #此处目录替换成自己电脑微信目录 import os
import zlib
import time
import re
#递归文件夹
def recursionFolder(path):
filename_regex = re.compile(r'.*\(\d+\)\..*')
crcList=list()
for root,dirs,files in os.walk(path):
for file in files:
print(os.path.join(root,file))
temp = filename_regex.search(file)
if temp != None:
os.remove(os.path.join(root,file))
if os.path.exists((os.path.join(root,file))):
fileCRC=crc32(os.path.join(root,file))
if fileCRC in crcList:
os.remove(os.path.join(root,file))
else:
crcList.append(fileCRC)
#获取文件crc值
def crc32(file_path):
with open(file_path, 'rb') as fh:
hash = 0
while True:
s = fh.read(65536)
if not s:
break
hash = zlib.crc32(s, hash)
return "%08X" % (hash & 0xFFFFFFFF)
recursionFolder("./") #此处目录替换成自己电脑微信目录
一名强迫症患者路过~ 怎么用这个?? 正好需要 谢谢楼主 看着很厉害,但是小白不会用。。 不能弄个工具吗..... 厉害,我试试看 厉害 我试试怎么样 挺不错的 bat批处理? 谢谢楼主分享
页:
[1]
2