From a8f9156b674e656a09e533a5bfb05b96384b5db0 Mon Sep 17 00:00:00 2001 From: tianyu Date: Wed, 29 Oct 2014 22:33:48 +0800 Subject: [PATCH] add -c (clean) --- z2t.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/z2t.sh b/z2t.sh index 0313cb5..3951fc5 100644 --- a/z2t.sh +++ b/z2t.sh @@ -1,5 +1,5 @@ #!/bin/bash -#title :z2t.sh +#title :z2t #description :This script will convert all zips(of jpg/bmp/png) with any content struct to tars(of jpg). Use "convert" command to convert images to jpg to depress disk space. the origin file's content struct will not change. #author :xdtianyu@gmail.com #date :20141029 @@ -8,6 +8,24 @@ #bash_version :4.3.11(1)-release #============================================================================== +if [ $1 = "-c" ]; then + echo "cleaning..." + cd tars + for file in *.tar; do + ZIP="${file%%.tar*}.zip" + echo "check \"$ZIP\" ..." + if [ -f "../$ZIP" ];then + echo "delete $ZIP ..." + rm -i "../$ZIP" + else + echo "$ZIP not exist." + fi + done + cd .. + rm -ri tars + exit 0 +fi + check_sub(){ echo "check sub." SAVEIFS=$IFS # setup this case the space char in file name.