Last active
October 6, 2017 17:37
-
-
Save dannofx/fc1e059b04ba809e5840b20da6f05211 to your computer and use it in GitHub Desktop.
Join several cbr or cbz files within in one single big cbz file, the order of the files in the final file will be determined alphabetically.
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 | |
if [ -z "$1" ] | |
then | |
echo "Specify the name of the file to create and the directory with the cbr files." | |
echo "./joincbr.sh YOUR_COMIC_FILE SOURCE_DIRECTORY" | |
exit 0 | |
fi | |
TARGET_NAME=$1 | |
SOURCE_DIRECTORY=$2 | |
export count=0 | |
find -E "$SOURCE_DIRECTORY" -regex '.*\.(cbr|cbz)' -type f -print0 | sort -z |while IFS= read -r -d '' file; do | |
extension=${file/*./} | |
dest=$(printf %06d $count)/ | |
if [ "$extension" == "cbr" ]; then | |
unrar x "$file" "$dest" | |
else | |
unzip -a "$file" -d "$dest" | |
fi | |
((count++)) | |
zip -ur "$TARGET_NAME.cbz" "$dest" | |
rm -fr "$dest" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment