python - 在 Windows 7 上比较 archiwum.rar 内容和从文件夹中的 .rar 中提取的数据

标签 python rar

有人知道如何比较 archiwum.rar 中的文件数量和文件大小及其在文件夹中提取的内容吗?

我想这样做的原因是,我正在使用的服务器在提取过程中已重新启动几次,我不确定是否所有文件都已正确提取。

.rar 文件每个都超过 100GB,服务器速度不是那么快。

有什么想法吗?

ps。如果解决方案是一些代码而不是独立程序,我更喜欢 Python。

谢谢

最佳答案

在Python中你可以使用RarFile模块。使用方法与内置模块ZipFile类似.

import rarfile
import os.path

extracted_dir_name = "samples/sample"    # Directory with extracted files
file = rarfile.RarFile("samples/sample.rar", "r")

# list file information
for info in file.infolist():
     print info.filename, info.date_time, info.file_size

     # Compare with extracted file here
     extracted_file = os.path.join(extracted_dir_name, info.filename)
     if info.file_size != os.path.getsize(extracted_file):
         print "Different size!"

关于python - 在 Windows 7 上比较 archiwum.rar 内容和从文件夹中的 .rar 中提取的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9410847/

相关文章:

linux - 为目录中的每个子目录创建一个 RAR 存档 - Centos/Ubuntu

php - 扫描多卷存档中的 .rar 文件内容条目

rar - 从拆分存档的部分中找到损坏的部分

python - 更改 DataFrame 的形状以进行分组

python - 尝试从多个位置导入模块的更简洁的方法?

python - 在不依赖 unrar.dll 的情况下使用 python 解压缩文件

algorithm - 如何确定 ZIP/RAR 文件的压缩方法

python - 多输出线性回归模型的访问权重/系数

python - 尝试仅将文件压缩到一个目录中

python - 打印 PyTorch 张量的精确值(浮点精度)