fff8e346ad
- Add optional directory argument to images_resize_recursive.sh, zip_images_resize_recursive.sh, and new rar2zip_recursive.sh - Remove hardcoded-path wrappers rar2zip_images.sh and rar2zip_incomplete.sh - Fix zip_images_resize.sh: move SCRIPT_DIR to top, change exit 1 to continue on bad output file so remaining files still process - Use MAX_PIXELS variable in images_resize.sh resize argument - Fix zip_images_recursive.sh: replace case-sensitive 7z globs with find -iregex piped via xargs
38 lines
880 B
Bash
Executable File
38 lines
880 B
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# zip_images_recursive Resizing large JPGs in current directory
|
|
# Based on: https://shkspr.mobi/blog/2016/12/converting-rar-to-zip-in-linux/
|
|
#
|
|
# Usage: xxx.sh
|
|
|
|
pushd () {
|
|
command pushd "$@" > /dev/null
|
|
}
|
|
|
|
popd () {
|
|
command popd "$@" > /dev/null
|
|
}
|
|
|
|
cwd=${PWD##*/}
|
|
directoryTree="${cwd}"
|
|
|
|
if [ "$#" -ne 0 ]; then
|
|
directoryTree="${1} - ${directoryTree}"
|
|
fi
|
|
|
|
mapfile -d '' jpgs < <(find . -maxdepth 1 -regextype posix-egrep -iregex ".*\.(jpg|jpeg)$" -print0)
|
|
|
|
if [ ${#jpgs[@]} -gt 0 ]; then
|
|
echo "Zipping JPGs in ${directoryTree}"
|
|
printf '%s\0' "${jpgs[@]}" | xargs -0 7z a -tzip -mx=0 "$directoryTree.zip"
|
|
fi
|
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
find . -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d '' subd; do
|
|
pushd "${subd}"
|
|
"$SCRIPT_DIR/zip_images_recursive.sh" "${directoryTree}"
|
|
popd
|
|
done
|