Monday, October 25, 2010
comicchangeWithoutSizechange
#!/bin/bash -
#===============================================================================
#
# FILE: compresszip.sh
#
# USAGE: ./compresszip.sh
#
# DESCRIPTION: for decompress the comic change the size and quality and compress it back
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: YOUR fullname (),
# COMPANY:
# CREATED: 08/26/2010 09:00:26 PM CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
set -x
# [ "$#" -lt 2 ] && echo "comicchange 80 comicfile" && exit 4
convert_zip_comic ()
{
if [ -d "$tmpfolder" ] ; then
#find $tmpfolder \( -iname \*jpg -o -iname \*png -o -iname tiff \) -exec convert -resize ${para}% -quality 80% "{}" "{}" \;
#zip -rqjm "$filename".zip $tmpfolder && rm -rf $tmpfolder
cd $tmpfolder && tar cf $workdir/"$filename".tar * && cd $workdir && rm -r $tmpfolder
fi
} # ---------- end of function decompress ----------
unzipcomic ()
{
if [ -n "${fullname}" ] ; then
unzip -nLqa "$fullname" -d $tmpfolder && rm "$fullname"
fi
} # ---------- end of function unzipcomic ----------
unrarcomic ()
{
if [ -n "${fullname}" ] ; then
mkdir "$tmpfolder" -p
unrar x -cl "$fullname" "$tmpfolder" && rm -rf "$fullname"
fi
} # ---------- end of function unrarcomic ----------
untarcomic ()
{
if [ -n "${fullname}" ] ; then
mkdir "$tmpfolder" -p
cd $tmpfolder; tar xpf $workdir/"$fullname"; cd $workdir; rm -rf "$fullname"
fi
} # ---------- end of function unrarcomic ----------
check_origFile ()
{
unzip -l tmp.zip | awk '{print $4}' | grep "\/$"
} # ---------- end of function check_origFile ----------
check_ext ()
{
case $extname in
zip)
unzipcomic $fullname
;;
rar)
unrarcomic $fullname
;;
tar)
untarcomic $fullname
;;
*)
echo "file not found"
;;
esac # --- end of case ---
#(([ "$extname" == "zip" ] && unzipcomic $fullname) || ( [ "$extname" == "rar" ] && unrarcomic $fullname )) || ([ "$extname" == "zip" ] && unzipcomic $fullname) || echo "file not found"
} # ---------- end of function check_ext ----------
extname=""
fullname=""
filename=""
tmpfolder=""
#para=$1
workdir=`pwd`
extname="${*##*.}"
filename="${*%%.*}"
fullname=$*
tmpfolder=/tmp/comicChange$RANDOM
check_ext
convert_zip_comic
#===============================================================================
#
# FILE: compresszip.sh
#
# USAGE: ./compresszip.sh
#
# DESCRIPTION: for decompress the comic change the size and quality and compress it back
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: YOUR fullname (),
# COMPANY:
# CREATED: 08/26/2010 09:00:26 PM CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
set -x
# [ "$#" -lt 2 ] && echo "comicchange 80 comicfile" && exit 4
convert_zip_comic ()
{
if [ -d "$tmpfolder" ] ; then
#find $tmpfolder \( -iname \*jpg -o -iname \*png -o -iname tiff \) -exec convert -resize ${para}% -quality 80% "{}" "{}" \;
#zip -rqjm "$filename".zip $tmpfolder && rm -rf $tmpfolder
cd $tmpfolder && tar cf $workdir/"$filename".tar * && cd $workdir && rm -r $tmpfolder
fi
} # ---------- end of function decompress ----------
unzipcomic ()
{
if [ -n "${fullname}" ] ; then
unzip -nLqa "$fullname" -d $tmpfolder && rm "$fullname"
fi
} # ---------- end of function unzipcomic ----------
unrarcomic ()
{
if [ -n "${fullname}" ] ; then
mkdir "$tmpfolder" -p
unrar x -cl "$fullname" "$tmpfolder" && rm -rf "$fullname"
fi
} # ---------- end of function unrarcomic ----------
untarcomic ()
{
if [ -n "${fullname}" ] ; then
mkdir "$tmpfolder" -p
cd $tmpfolder; tar xpf $workdir/"$fullname"; cd $workdir; rm -rf "$fullname"
fi
} # ---------- end of function unrarcomic ----------
check_origFile ()
{
unzip -l tmp.zip | awk '{print $4}' | grep "\/$"
} # ---------- end of function check_origFile ----------
check_ext ()
{
case $extname in
zip)
unzipcomic $fullname
;;
rar)
unrarcomic $fullname
;;
tar)
untarcomic $fullname
;;
*)
echo "file not found"
;;
esac # --- end of case ---
#(([ "$extname" == "zip" ] && unzipcomic $fullname) || ( [ "$extname" == "rar" ] && unrarcomic $fullname )) || ([ "$extname" == "zip" ] && unzipcomic $fullname) || echo "file not found"
} # ---------- end of function check_ext ----------
extname=""
fullname=""
filename=""
tmpfolder=""
#para=$1
workdir=`pwd`
extname="${*##*.}"
filename="${*%%.*}"
fullname=$*
tmpfolder=/tmp/comicChange$RANDOM
check_ext
convert_zip_comic
comicchange
#!/bin/bash -
#===============================================================================
#
# FILE: compresszip.sh
#
# USAGE: ./compresszip.sh
#
# DESCRIPTION: for decompress the comic change the size and quality and compress it back
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: YOUR fullname (),
# COMPANY:
# CREATED: 08/26/2010 09:00:26 PM CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
set -x
[ "$#" -lt 2 ] && echo "comicchange 80 comicfile" && exit 4
convert_zip_comic ()
{
if [ -d "$tmpfolder" ] ; then
find $tmpfolder \( -iname \*jpg -o -iname \*png -o -iname tiff \) -exec convert -resize ${para}% -quality 80% "{}" "{}" \;
#zip -rqjm "$filename".zip $tmpfolder && rm -rf $tmpfolder
cd $tmpfolder && tar cf $workdir/"$filename".tar * && cd $workdir && rm -r $tmpfolder
fi
} # ---------- end of function decompress ----------
unzipcomic ()
{
if [ -n "${fullname}" ] ; then
unzip -nLqa "$fullname" -d $tmpfolder && rm "$fullname"
fi
} # ---------- end of function unzipcomic ----------
unrarcomic ()
{
if [ -n "${fullname}" ] ; then
mkdir "$tmpfolder" -p
unrar x -cl "$fullname" "$tmpfolder" && rm -rf "$fullname"
fi
} # ---------- end of function unrarcomic ----------
untarcomic ()
{
if [ -n "${fullname}" ] ; then
mkdir "$tmpfolder" -p
cd $tmpfolder; tar xpf $workdir/"$fullname"; cd $workdir; rm -rf "$fullname"
fi
} # ---------- end of function unrarcomic ----------
check_origFile ()
{
unzip -l tmp.zip | awk '{print $4}' | grep "\/$"
} # ---------- end of function check_origFile ----------
check_ext ()
{
case $extname in
zip)
unzipcomic $fullname
;;
rar)
unrarcomic $fullname
;;
tar)
untarcomic $fullname
;;
*)
echo "file not found"
;;
esac # --- end of case ---
#(([ "$extname" == "zip" ] && unzipcomic $fullname) || ( [ "$extname" == "rar" ] && unrarcomic $fullname )) || ([ "$extname" == "zip" ] && unzipcomic $fullname) || echo "file not found"
} # ---------- end of function check_ext ----------
extname=""
fullname=""
filename=""
tmpfolder=""
para=$1
workdir=`pwd`
extname="${2##*.}"
filename="${2%%.*}"
fullname=$2
tmpfolder=/tmp/comicChange$RANDOM
check_ext
convert_zip_comic
#===============================================================================
#
# FILE: compresszip.sh
#
# USAGE: ./compresszip.sh
#
# DESCRIPTION: for decompress the comic change the size and quality and compress it back
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: YOUR fullname (),
# COMPANY:
# CREATED: 08/26/2010 09:00:26 PM CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
set -x
[ "$#" -lt 2 ] && echo "comicchange 80 comicfile" && exit 4
convert_zip_comic ()
{
if [ -d "$tmpfolder" ] ; then
find $tmpfolder \( -iname \*jpg -o -iname \*png -o -iname tiff \) -exec convert -resize ${para}% -quality 80% "{}" "{}" \;
#zip -rqjm "$filename".zip $tmpfolder && rm -rf $tmpfolder
cd $tmpfolder && tar cf $workdir/"$filename".tar * && cd $workdir && rm -r $tmpfolder
fi
} # ---------- end of function decompress ----------
unzipcomic ()
{
if [ -n "${fullname}" ] ; then
unzip -nLqa "$fullname" -d $tmpfolder && rm "$fullname"
fi
} # ---------- end of function unzipcomic ----------
unrarcomic ()
{
if [ -n "${fullname}" ] ; then
mkdir "$tmpfolder" -p
unrar x -cl "$fullname" "$tmpfolder" && rm -rf "$fullname"
fi
} # ---------- end of function unrarcomic ----------
untarcomic ()
{
if [ -n "${fullname}" ] ; then
mkdir "$tmpfolder" -p
cd $tmpfolder; tar xpf $workdir/"$fullname"; cd $workdir; rm -rf "$fullname"
fi
} # ---------- end of function unrarcomic ----------
check_origFile ()
{
unzip -l tmp.zip | awk '{print $4}' | grep "\/$"
} # ---------- end of function check_origFile ----------
check_ext ()
{
case $extname in
zip)
unzipcomic $fullname
;;
rar)
unrarcomic $fullname
;;
tar)
untarcomic $fullname
;;
*)
echo "file not found"
;;
esac # --- end of case ---
#(([ "$extname" == "zip" ] && unzipcomic $fullname) || ( [ "$extname" == "rar" ] && unrarcomic $fullname )) || ([ "$extname" == "zip" ] && unzipcomic $fullname) || echo "file not found"
} # ---------- end of function check_ext ----------
extname=""
fullname=""
filename=""
tmpfolder=""
para=$1
workdir=`pwd`
extname="${2##*.}"
filename="${2%%.*}"
fullname=$2
tmpfolder=/tmp/comicChange$RANDOM
check_ext
convert_zip_comic