从 python 编辑 .RAR 文件注释
好的,我需要能够从 python 编辑 .rar 文件中的文件注释。
我已经可以使用 UnRAR 查看评论。但是,我需要以在多个文件系统上保留的方式将元数据嵌入到文件中(例如,备用数据流已消失),所以我真的无法想到任何其他替代方案。
rarfile 似乎可能有效,但事实并非如此尽管它声称具有平台独立性(或者 .rar 格式已更改,但考虑到同一时期工作的其他实用程序,这似乎不太可能),但它确实在 Windows 下正常运行。它可以很好地打开档案,但它无法识别有评论。
先发制人地回答一些不可避免的评论 -
不,我无法转换档案(有数千个)。
任何依赖于文件系统的元数据存储模式都已过时,因为我需要支持 NTFS、XFS 和 ext3。
隐藏文件会很混乱,您需要确保它们与关联文件一起移动,但我无法做到这一点。
Ok, I need to be able to edit the file comments in .rar files from python.
I can already view the comments using UnRAR. However, I need to embed metadata in the files in a way that is preserved over multiple file systems (e.g. alternate datastreams are out), so I can't really think of any other alternatives.
rarfile seems like it might work, but it doesn't really function correctly under windows, despite it's claim of platform independence (or the .rar format has changed, but that seems unlikely considering other utilities from the same time period work). It opens the archive fine, but it does not recognize that there are comments.
To pre-emptively answer some of the inevitable comments -
No, I cannot convert the archives (there's thousands of them).
Any file-system-dependent mode of storing metadata is out, as I need to support NTFS, XFS and ext3.
Hidden files would be a mess, and you need to ensure they are moved with the associated file, which I cannot do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你不走运。不幸的是,RAR 格式是闭源的,没有文档记录,并且没有 Python 模块可以完成您想做的事情。
据我所知,唯一可以解压缩 RAR 文件的开源工具是 The Unarchiver。我认为您最好的选择是检查他们的 来源 并编写您自己的 Python 工具来更改文件注释。
您也可以尝试在 comp.compression 板,我有一个类似的 几年前出现了一个晦涩的压缩格式问题,那里的人很快就能够帮助我。
I think you are out of luck. Unfortunately the RAR format is closed source and not documented, and there is no Python module that does what you want to do.
The only open-source tool I know that uncompress RAR files is The Unarchiver. I think that your best bet is check their sources and write your own Python tool to change the file comments.
You might also try to ask this question at the comp.compression boards, I had a similar issue some years ago with an obscure compression format and the people over there were able to help me in no time.