turquoise-turtle/cbz-merger
A cli-tool to merge several CBZ files into one main archive, or several archives divided by volume.
- Contents :toc:
- [[#what-is-it][What is it?]]
- [[#why-use-it][Why use it?]]
- [[#export-modes][Export modes]]
- [[#pre-requisites][Pre-requisites]]
- [[#apt-package-manager-debian--ubuntu--linux-mint][APT package manager (Debian / Ubuntu / Linux Mint)]]
- [[#arch-linux][Arch Linux]]
- [[#dnf-package-manager-fedora][DNF package manager (Fedora)]]
- [[#yum-package-manager-redhat--rhel--centos][Yum package manager (Redhat / RHEL / CentOS)]]
- [[#installation][Installation]]
- [[#usage][Usage]]
- [[#create-a-single-archive-file][Create a single archive file]]
- [[#create-a-file-per-volume][Create a file per volume]]
- [[#closing-thoughts][Closing thoughts]]
-
What is it?
A cli-tool to merge several CBZ (zip) files into one main archive, or several archives divided by volume. -
Why use it?
Works great if you download full comics/mangas, which come in come organized in CBZ files (one CBZ per chapter, each one containing
one image per page).
That's a lot of images!
And if you would rather organize them in a single main file, or a file per volume, this tool will do the work for you.
This is also great if you read them on some kind of e-reader, like Kobo, since you will have less files to manage.
[[./imgs/cbz-showcase.png]]
- Export modes
You can merge all your files into one of the two following options:
- One main file containing all the pages of your comic/manga.
- One file per volume, each one containing only the pages of its chapters.
Each of these can be exported into either PDF, or CBZ.
- Pre-requisites
You'll need:
- Python3
- pip
- Your CBZ files should have ordered alphabetically. (This should be de default if you download in bulk your mangas, because they should come sorted in some way so that you can easily read each chapter in order)
I'm using Python 3.9.5, so if you got any problems, try to use at least
this version.
Get the latest version in your favorite Linux flavor.
(Snipets taken from [[https://www.csestack.org/install-python-on-linux/][CSEstack]] and [[https://linuxconfig.org/install-pip-on-linux/][linuxconfig]])
** APT package manager (Debian / Ubuntu / Linux Mint)
#+begin_src sh
First update your local system's repository list
sudo apt-get update
Install python3
sudo apt-get install python
Install pip for python3
sudo apt install python3-pip
#+end_src
** Arch Linux
#+begin_src sh
Install python3
sudo pacman -S python
Install pip
sudo pacman -S python-pip
#+end_src
** DNF package manager (Fedora)
#+begin_src sh
This installs both python and pip, in a nice little bundle. How convenient!
sudo dnf install python3
#+end_src
** Yum package manager (Redhat / RHEL / CentOS)
#+begin_src sh
Install python3
sudo yum install python
pip is not available on core repositories, so you'll need this
sudo yum install epel-release
Now you can actually install pip
sudo yum install python-pip
#+end_src
- Installation
You'll need to:
- Clone the repository
- Move inside the repo's directory
- [Optional] Create a virtual environment
This might not be obligatory, but is highly recommendable to have a virtual environment for each project, to avoid conflicts between libraries and
versions. - Install the requirements (remember that you need Python for this)
#+begin_src sh
Get the repo
git clone https://github.com/LeobardoArguelles/cbz-merger.git
cd cbz-merger
Create a virtual environment
pip install virtualenv
python -m venv venv
Activate the virtual environment
source venv/bin/activate
Install the requirements
pip install -r requirements.txt
#+end_src
Then go into usage.
- Usage
Remember that you have to be inside the directory of your cloned repository.
From there, you can:
- Merge all your CBZs into a single file
- Merge your CBZ files by volume
Both of these can be exported to:
- CBZ
** Create a single archive file
#+begin_src sh
One of either:
Create CBZ archive
python ./merge.py <path/to/cbzs/directory> -a
Convert to PDF
python ./merge.py <path/to/cbzs/directory> -a --pdf
#+end_src
Where:
- <path/to/cbz/directory> is the path to the directory that contains all the CBZ files to be merged.
- is how you want to name the final file.
*** Example
Using a file structure where your CBZs are stored inside a directory called "mangas":
#+begin_example
/
│
├── share
│ └── mangas <-- This is the directory we want!
│ ├ [Vol 00] Chapter 1.cbz
│ ├ [Vol 00] Chapter 2.cbz
│ ├ [Vol 00] Chapter 3.cbz
│ ├ [Vol 00] Chapter 4.cbz
│ ├ ...
│ └ [Vol 19] Chapter 268.cbz
....
#+end_example
- Using this structure, our path would be:
/share/mangas - Assume we want to call our archive as:
myArchive - And finally, we want to generate it as a CBZ, so we won't use the
--pdfoption.
Then, we would run the command as:
#+begin_src sh
python ./merge.py /share/mangas -a myArchive
#+end_src
** Create a file per volume
This is great if you would rather to have several smaller files per
volume, instead of having one monolithic main file with thousands
of images.
#+begin_src sh
One of either:
Each volume is a CBZ archive
python ./merge.py <path/to/cbzs/directory> -vo ""
Each volume is a PDF file
python ./merge.py <path/to/cbzs/directory> -vo "" --pdf
#+end_src
Where:
- <path/to/cbz/directory> is the path to the directory that contains all the CBZ files to be merged.
- is a [[https://docs.python.org/3/howto/regex.html][regular expression]] that tells the program the naming convention of your volumes.
Note that you don't need to specify an output name (like when
generating an archive), because the files will be named just like
the volumes.
*** Example
To use this mode your CBZ files must have their volume in their name.
For example, using the same structure as in the previous example:
#+begin_example
/
│
├── share
│ └── mangas <-- This is the directory we want!
│ ├ [Vol 00] Chapter 1.cbz
│ ├ [Vol 00] Chapter 2.cbz
│ ├ [Vol 00] Chapter 3.cbz
│ ├ [Vol 00] Chapter 4.cbz
│ ├ ...
│ └ [Vol 19] Chapter 268.cbz
....
#+end_example
- Our path would be:
/share/mangas - We want to output a PDF file per volume, so we use
--pdf. - Our regex could be either
Vol \d\dorVol \d{2}.
Then, we would run:
#+begin_src sh
python ./merge.py /share/mangas -vo "Vol \d\d" --pdf
#+end_src
- Closing thoughts
This is the first tool that I actually release for public usage.
I made it for myself, but I tried to generalize it so that it can be used by other persons.
I hope that you find it helpful.
If you have any problem feel free to open an issue, and if you've got suggestions or ideas to expand this tool,
I would love for you to get in touch.