|
|
@ -1,12 +1,13 @@ |
|
|
|
from getFiles import get_file_list |
|
|
|
from getFiles import get_file_list |
|
|
|
from getMd5 import get_file_md5 |
|
|
|
from getMd5 import get_file_md5 |
|
|
|
from db import * |
|
|
|
from db import * |
|
|
|
|
|
|
|
from time import time as t |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main_process(): |
|
|
|
def main_process(): |
|
|
|
disk = "Myxx_Backup_16T_2" |
|
|
|
disk = "Myxx_Backup_16T_3" |
|
|
|
cate = "hj" |
|
|
|
cate = "leshe" |
|
|
|
path = r"Y:\hj" |
|
|
|
path = r"X:\leshe" |
|
|
|
|
|
|
|
|
|
|
|
_exist_file_list = [] |
|
|
|
_exist_file_list = [] |
|
|
|
|
|
|
|
|
|
|
@ -14,14 +15,27 @@ def main_process(): |
|
|
|
print("检查参数") |
|
|
|
print("检查参数") |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(f"开始获取文件列表:{t()}") |
|
|
|
file_list = get_file_list(path) |
|
|
|
file_list = get_file_list(path) |
|
|
|
file_list_len = len(file_list) |
|
|
|
print(f"结束获取文件列表:{t()}") |
|
|
|
for (i, f) in enumerate(file_list): |
|
|
|
|
|
|
|
print(f"({i+1}/{file_list_len}) - 开始处理: {f}") |
|
|
|
unchecked_list = [] |
|
|
|
if md5 := get_md5_by_path(f): |
|
|
|
cate_file_list = get_path_by_cate(cate) |
|
|
|
print(f"请注意!!!文件的md5({md5})已经存在: {f}") |
|
|
|
|
|
|
|
|
|
|
|
total_len = len(file_list) |
|
|
|
|
|
|
|
for (index, file) in enumerate(file_list): |
|
|
|
|
|
|
|
if file[2:] in cate_file_list: |
|
|
|
|
|
|
|
print(f"{index}/{total_len}文件已经存在: {file}") |
|
|
|
else: |
|
|
|
else: |
|
|
|
|
|
|
|
print(f"{index}/{total_len}未处理文件: {file}") |
|
|
|
|
|
|
|
unchecked_list.append(file) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file_list_len = len(unchecked_list) |
|
|
|
|
|
|
|
for (i, f) in enumerate(unchecked_list): |
|
|
|
|
|
|
|
print(f"({i+1}/{file_list_len}) - 开始处理: {f} - {t()}") |
|
|
|
|
|
|
|
t_start = t() |
|
|
|
md5 = get_file_md5(f) |
|
|
|
md5 = get_file_md5(f) |
|
|
|
|
|
|
|
print(f"完成MD5计算耗时:{t()-t_start}") |
|
|
|
if exist := is_exist(md5): |
|
|
|
if exist := is_exist(md5): |
|
|
|
_exist_file_list.append(f) |
|
|
|
_exist_file_list.append(f) |
|
|
|
print(f"重复文件!!!md5为({md5})的文件已经存在,文件路径:{exist['path']} -> {f}") |
|
|
|
print(f"重复文件!!!md5为({md5})的文件已经存在,文件路径:{exist['path']} -> {f}") |
|
|
@ -33,5 +47,11 @@ def main_process(): |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
exist_file_list = main_process() |
|
|
|
exist_file_list = main_process() |
|
|
|
|
|
|
|
if len(exist_file_list) > 0: |
|
|
|
|
|
|
|
with open('dup.txt', 'w', encoding='utf-8') as dup_file: |
|
|
|
for ef in exist_file_list: |
|
|
|
for ef in exist_file_list: |
|
|
|
print(ef) |
|
|
|
print(ef) |
|
|
|
|
|
|
|
dup_file.write(ef) |
|
|
|
|
|
|
|
dup_file.close() |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
print("没有找到重复文件") |
|
|
|