Initial commit
This commit is contained in:
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/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
|
||||
|
||||
jpgs=$(find . -maxdepth 1 -regextype posix-egrep -regex ".*\.(jpg|JPG|JPEG|jpeg)$")
|
||||
|
||||
if [ -n "$jpgs" ]; then
|
||||
echo "Zipping JPGs in ${directoryTree}"
|
||||
7z a -tzip -mx=0 "$directoryTree.zip" "*.jpg" -i!*.jpeg -i!*.JPG -i!*.JPEG
|
||||
fi
|
||||
|
||||
|
||||
for subd in *; do
|
||||
if [ -d "${subd}" ]; then
|
||||
pushd "${subd}"
|
||||
~/zip_images_recursive.sh "${directoryTree}"
|
||||
popd
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user