General Enhancements #2
@ -34,9 +34,12 @@ function usage() {
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
-s SIZE : Integer for the maximum length of either image dimension.
|
-s SIZE : Integer for the maximum length of either image dimension.
|
||||||
|
Default size is 2000.
|
||||||
-l LOCATION : The specific image or folder which needs images shrunk.
|
-l LOCATION : The specific image or folder which needs images shrunk.
|
||||||
|
Default location is the current directory.
|
||||||
-r : Recursively shrink images based on the location passed.
|
-r : Recursively shrink images based on the location passed.
|
||||||
-f : Force the image to be shrunk even if a file already exists for it.
|
-f : Force the image to be shrunk even if a file already exists for it.
|
||||||
|
-F : FORCE the image to be shrunk even if the file is already shrunk.
|
||||||
-d : Delete the original image if the compressed image is smaller.
|
-d : Delete the original image if the compressed image is smaller.
|
||||||
-c : Clean the filename of underscores, dashes, 'IMG', etc.
|
-c : Clean the filename of underscores, dashes, 'IMG', etc.
|
||||||
-A : Resursively Force, Delete, and Clean.
|
-A : Resursively Force, Delete, and Clean.
|
||||||
@ -48,12 +51,13 @@ function usage() {
|
|||||||
|
|
||||||
## Parameters ##
|
## Parameters ##
|
||||||
|
|
||||||
while getopts ":s:l:rfdcAhx" opt; do
|
while getopts ":s:l:rfFdcAhx" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
s) in_size="$OPTARG" && size="$in_size" ;;
|
s) in_size="$OPTARG" && size="$in_size" ;;
|
||||||
l) location="$OPTARG" ;;
|
l) location="$OPTARG" ;;
|
||||||
r) recurse="Y" && search="find" ;;
|
r) recurse="Y" && search="find" ;;
|
||||||
f) force="Y" ;;
|
f) force="Y" ;;
|
||||||
|
F) super_force="Y" ;;
|
||||||
d) delete="Y" ;;
|
d) delete="Y" ;;
|
||||||
c) clean="Y" ;;
|
c) clean="Y" ;;
|
||||||
A) recurse="Y" && search="find" && force="Y" && delete="Y" && clean="Y" ;;
|
A) recurse="Y" && search="find" && force="Y" && delete="Y" && clean="Y" ;;
|
||||||
@ -90,8 +94,8 @@ $search "$location" | sort | while read image; do
|
|||||||
# Avoid processing directories no matter the name.
|
# Avoid processing directories no matter the name.
|
||||||
[ -d "$image" ] && continue
|
[ -d "$image" ] && continue
|
||||||
|
|
||||||
# Avoid processing files previously shrunk.
|
# Avoid processing files previously shrunk, unless we are FORCEing.
|
||||||
[[ "$image" == *"$tag"* ]] && continue
|
[[ "$image" == *"$tag"* && -z "$super_force" ]] && continue
|
||||||
|
|
||||||
echo -e "\n$image"
|
echo -e "\n$image"
|
||||||
|
|
||||||
@ -107,7 +111,7 @@ $search "$location" | sort | while read image; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
new_image="${image//.$extension/}.$tag-$date_YYYYMMDD.$extension"
|
new_image="${image//.$extension/}.$tag-$date_YYYYMMDD-$size.$extension"
|
||||||
|
|
||||||
## Clean Filename ##
|
## Clean Filename ##
|
||||||
# Prevent directory from having its name cleaned too.
|
# Prevent directory from having its name cleaned too.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user