列出 LZMA 压缩文件的内容?
是否可以在不解压缩整个文件的情况下列出 LZMA 文件 (.7zip) 的内容?另外,我可以从 LZMA 文件中提取单个文件吗?
我的问题:我有一个 30GB .7z 文件,解压后大小为 >5TB。我想操作原始 .7z 文件而不需要完全解压缩。
Is it possible to list the contents of a LZMA file (.7zip) without uncompressing the whole file? Also, can I extract a single file from the LZMA file?
My problem: I have a 30GB .7z file that uncompresses to >5TB. I would like to manipulate the original .7z file without needing to do a full uncompress.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的。从XZ Utils开始。有 Perl 和 Python API。
您可以从标题中找到您想要的文件。每个文件都是单独压缩的,因此您可以只提取您想要的文件。
Yes. Start with XZ Utils. There are Perl and Python APIs.
You can find the file you want from the headers. Each file is compressed separately, so you can extract just the one you want.
从 Sourceforge 上的 LZMA SDK 文件页面下载 lzma922.tar.bz2,然后解压文件并打开 C/Util/7z/7zMain.c。在那里,您将找到从 .7z 存档中提取特定存档文件的例程。您不需要从所有条目中提取所有数据,示例代码显示了如何仅提取您感兴趣的数据。这段相同的代码具有列出条目的逻辑,而无需提取所有压缩数据。
Download lzma922.tar.bz2 from the LZMA SDK files page on Sourceforge, then extract the files and open up C/Util/7z/7zMain.c. There, you will find routines to extract a specific archive file from a .7z archive. You don't need to extract all the data from all the entries, the example code shows how to extract just the one you are interested in. This same code has logic to list the entries without extracting all the compressed data.
我通过安装 7zip (https://www.7-zip.org/) 解决了这个问题并使用参数l。例如:
输出有一些描述性信息以及压缩文件中的文件列表。然后,我使用 subprocess 库在 python 中调用它:
不要忘记确保程序 7z 可在 PATH 变量中访问。我必须在 Windows 中手动执行此操作。
I solved this problem by installing 7zip (https://www.7-zip.org/) and using the parameter l. For example:
The output has some descriptive information and the list of files in the compressed files. Then, I call this inside python using the subprocess library:
Don't forget to make sure the program 7z is accessible in your PATH variable. I had to do this manually in Windows.