Vai al contenuto
Home » Convert Comics Cbr/Cbz to Pdf with AllCbrztoPdf

Convert Comics Cbr/Cbz to Pdf with AllCbrztoPdf

Convert Comics Cbr/Cbz to Pdf with AllCbrztoPdf
Convert Comics Cbr/Cbz to Pdf with AllCbrztoPdf

How to Convert Comics Cbr/Cbz to Pdf with AllCbrztoPdf. One of the most common problems that users face is converting comic image files, such as CBR and CBZ files, to PDF format. To solve this problem, I have created AllCbrztoPdf, a Bash script that greatly simplifies this process.

The script is designed to automatically convert CBR and CBZ files to PDF format using a series of standard Bash commands, making the conversion of large amounts of files a simple and fast task. Running the script is simple. Once executed, it will download and install the necessary programs for distributions such as Debian based and SysLinuxOS, then prompt the user to select a main folder via Zenity and subsequently start converting all CBR and CBZ files to PDF format within the folder and its subfolders. During the conversion, the script will display the progress using pv and create a single combined PDF file using pdftk. Finally, the script will save the resulting PDF file in the same folder where the original file was located. By default, it will only leave the PDF files and DELETE ALL CBR and CBZ files.

Download via GitHub

$ git clone https://github.com/fconidi/AllCbrztoPdf.git
$ cd AllCbrztoPdf/
$ chmod +x allcbrztopdf.sh
$ ./allcbrztopdf.sh

Download via SourceForge

For other linux distributions, the strings with sudo can be commented out/deleted, and the packages can be installed through the package manager. If you want to keep the CBR/CBZ files, just comment out the rm “$file” string at the end.

AllCbrztoPdf complete script:

#!/bin/bash
set -xev
sudo apt update
sudo apt upgrade -y
sudo apt install -y pv imagemagick pdftk img2pdf unrar-free rar unrar p7zip-full

# Select the root folder
folder=$(zenity –file-selection –directory –title=”Select the root folder”)

# Rename all files .cbr to .rar and .cbz to .zip (recursively)
find “$folder” -type f -name “*.cbr” -execdir rename ‘s/ /_/g’ ‘{}’ \;
find “$folder” -type f -name “*.cbr” -execdir mv ‘{}’ ‘{}’.rar \;
find “$folder” -type f -name “*.cbz” -execdir rename ‘s/ /_/g’ ‘{}’ \;
find “$folder” -type f -name “*.cbz” -execdir mv ‘{}’ ‘{}’.zip \;

# Convert all files .cbr and .cbz to PDF (recursively)
find “$folder” -type f \( -name “*.rar” -o -name “*.cbr” -o -name “*.zip” -o -name “*.cbz” \) |
while read file; do
ORIGINAL_FOLDER=$(dirname “$file”)
TMP_FOLDER=$(mktemp -d)
cd “$TMP_FOLDER”
case “$file” in
*.rar|*.cbr)
unrar e “$file” “$TMP_FOLDER”
;;
*.zip|*.cbz)
unzip -j “$file” -d “$TMP_FOLDER”
;;
esac
ls -1 ./*jpg ./*jpeg ./*png | pv -lep -s $(ls -1 ./*jpg ./*jpeg ./*png | wc -l) | xargs -L1 -I {} img2pdf {} -o {}.pdf
pdftk *.pdf cat output combined.pdf
cp “$TMP_FOLDER/combined.pdf” “$ORIGINAL_FOLDER/$(basename “$file” .cbr | sed ‘s/.rar$//;s/.zip$//;s/.cbz$//’).pdf”
rm -rf “$TMP_FOLDER”
rm “$file”
done

zenity –info –text=”Conversion completed!”

PS: the last update script is on GitHub or SourceForge

 
Convert Comics Cbr/Cbz to Pdf with AllCbrztoPdf

Video:

 

enjoy 😉

 

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *