views:

96

answers:

1

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.

+1  A: 

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.

Cesar Canassa