Python 扫描目录

def ScanDir(file_list,proc_parent_path,MD5_list,err_list):
    for root,dirs,files in os.walk(proc_parent_path):
        for file_name in files:
            file_path = os.path.join(root + os.sep + file_name)
            if os.path.isfile(file_path):
                MD5Code = GetFileMD5(file_path)
                if MD5Code:
                    file_size = os.path.getsize(file_path)
                    try:
                        if MD5_list.index([file_size,MD5Code]) >= 0 :
                            err_list.append([file_path, file_size, MD5Code, "The file already exists"])
                    except ValueError:
                        file_list.append([file_path, file_size, MD5Code])
                        MD5_list.append([file_size, MD5Code])
                else:
                    err_list.append([file_path,os.path.getsize(file_path),MD5Code,"Get MD5 Failed"])

自己写的扫描目录,生成文件目录、MD5值(包括MD5值检测)、重复错误数据

你可能感兴趣的:(python,list,File,Path)