import os
import hashlib
def hash (path, method=hashlib.md5):
h = method ()
with open (path, 'rb') as f:
while b := f.read (8192):
h.update (b)
return h.hexdigest ()
q = dict ()
for root, _, k in os.walk ('.'):
for d in k:
i = root + '/' + d
print (i)
h = hash (i)
print (h)
if h in q:
print (f'{i} (Cached from {q[h]})')
os.system (f'ln -sf {q[h]} {i}')
else:
print (f'{i} (Uncached)')
q[h] = i
目录下重复文件自动转成符号链接。仅 Linux
2025-08-20 18:48:34 By ryp
评论
暂无评论
发表评论
可以用@mike来提到mike这个用户,mike会被高亮显示。如果你真的想打“@”这个字符,请用“@@”。