Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active May 17, 2024 10:19
Turn RAR into ZIP in Python. For further details: https://kb.aspose.com/zip/python/turn-rar-into-zip-in-python/
import aspose.zip as az
from io import BytesIO
# Create ZIP archive
with az.Archive() as zip:
# Load RAR file
with az.rar.RarArchive("Sample.rar") as rar:
# Loop through entries
for i in range(rar.entries.length):
# Move entries from RAR to ZIP
if not rar.entries[i].is_directory:
ms = BytesIO()
rar.entries[i].extract(ms)
zip.create_entry(rar.entries[i].name, ms)
# Save ZIP archive
zip.save("rar_to_zip.zip")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment