Last active
September 21, 2017 18:23
-
-
Save dannofx/e1e11db6da640269ea89d3d1a2a293f3 to your computer and use it in GitHub Desktop.
Compress easch subdirectoryinside a directory to a cbz file
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 source directory." | |
echo "./joincbr.sh SOURCE_DIRECTORY" | |
exit 0 | |
fi | |
SOURCE_DIRECTORY=$1 | |
COLLECTION_NAME=$2 | |
if ! [ -z "$COLLECTION_NAME" ] | |
then | |
mkdir "$COLLECTION_NAME" | |
fi | |
export count=0 | |
find "$SOURCE_DIRECTORY" -name "*" -maxdepth 1 -mindepth 1 -type d -print0 | sort -z |while IFS= read -r -d '' file; do | |
#dest="$count/" | |
filename="${file##/*/}" | |
cbzfile="$COLLECTION_NAME $filename.cbz" | |
echo "Creating cbr file: $cbzfile" | |
ditto -c -k -X "$file" "$cbzfile" | |
if ! [ -z "$COLLECTION_NAME" ] | |
then | |
mv "$cbzfile" "$COLLECTION_NAME/" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment