Last active
May 17, 2024 10:19
-
-
Save aspose-com-kb/2da940631d667497d666f4709d7d1332 to your computer and use it in GitHub Desktop.
Turn RAR into ZIP in Python. For further details: https://kb.aspose.com/zip/python/turn-rar-into-zip-in-python/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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