Created
November 21, 2024 12:57
-
-
Save kompowiec/3a7564ffcc691ee033fde310884cc0fd to your computer and use it in GitHub Desktop.
CBR to CBZ converter
This file contains hidden or 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
| #!/bin/bash | |
| # Find all CBR files recursively and process each | |
| find . -type f -iname '*.cbr' | while read -r cbr_file; do | |
| # Extract the directory and file name without extension | |
| dir=$(dirname "$cbr_file") | |
| base=$(basename "$cbr_file" .cbr) | |
| # Create a temporary folder for extraction | |
| temp_dir="${dir}/${base}_temp" | |
| mkdir -p "$temp_dir" | |
| # Extract CBR contents | |
| echo "Extracting: $cbr_file" | |
| unrar x -o+ "$cbr_file" "$temp_dir/" || { echo "Extraction failed for $cbr_file"; continue; } | |
| # Compress the extracted files into a CBZ | |
| cbz_file="${dir}/${base}.cbz" | |
| echo "Creating CBZ: $cbz_file" | |
| zip -r "$cbz_file" "$temp_dir"/* > /dev/null || { echo "Failed to create CBZ for $cbr_file"; rm -r "$temp_dir"; continue; } | |
| # Clean up | |
| rm -r "$temp_dir" | |
| # Optional: Delete the original CBR file | |
| # Uncomment the next line if you want to remove CBR files after conversion | |
| # rm "$cbr_file" | |
| echo "Converted: $cbr_file → $cbz_file" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To convert CBR to CBZ recursively in a directory structure, you can use a script. Is a script for Linux/Unix (Bash) or Windows with tools like Git Bash installed.
What It Does:
.cbrfiles recursively usingfind..cbrinto a temporary folder usingunrar..cbzusingzip..cbrfile.Notes:
.cbzfiles unless explicitly set.unrarandzipare installed..cbrfiles after conversion if desired.