Created
July 16, 2024 08:43
-
-
Save sleeyax/7bbdd314c8de2adda4c82e4f66ea2f46 to your computer and use it in GitHub Desktop.
Convert CBR (supports media type `application/x-rar-compressed; version=5`) to CBZ
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 os | |
import shutil | |
import patoolib | |
input_directory = '/path/to/input/direcotry' | |
# List of filenames | |
filenames = [ | |
'01 - Example comic 1 (2020)', | |
'02 - Example comic 2 (2020)', | |
'03 - Example comic 3 (2020)' | |
] | |
for filename in filenames: | |
rar_file_path = os.path.join(input_directory, filename + ".cbr") | |
if os.path.exists(rar_file_path): | |
# Convert RAR to CBZ (ZIP with .cbz extension) | |
cbz_file_path = os.path.join(input_directory, filename + '.cbz') | |
print(f"Processing '{rar_file_path}'") | |
patoolib.repack_archive(rar_file_path, cbz_file_path) | |
# Delete the original RAR file from directory A | |
os.remove(rar_file_path) | |
else: | |
print(f"File '{rar_file_path}' not found") | |
print("Process completed successfully.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
$ python -m venv .venv $ source .venv/bin/activate $ pip install patool $ python main.py