From 7b4d17d4c3f676b7e4df2c2efaed27d82d171f81 Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Wed, 17 Feb 2016 10:20:22 +0200 Subject: [PATCH] added version number and info how to remove sources --- files/archive_subfolders | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/files/archive_subfolders b/files/archive_subfolders index dc70fd8..352020e 100755 --- a/files/archive_subfolders +++ b/files/archive_subfolders @@ -1,9 +1,10 @@ #!/bin/bash +VERSION="20160217" function helpexit() { BS=$( basename "$0" ) - echo Archive the subfolders of the current directory + echo "Archive the subfolders of the current directory, version: $VERSION" echo "Usage: $BS [-z/-n] [folder name(s)]" echo " -z Compress. If not given, will ask action after archiving" echo " -n No compression. Exit after TARchive" @@ -23,6 +24,12 @@ function fsize() { function killtrap() { kill "$PID" &>/dev/null } +function exitokay() { + echo -ne "\nIf all looks okay, delete source folders with: # rm -r '" + listfolders "${FOLDERS[@]}" | sed -e "s/\x0/' '/g" -e "s,..$,," + echo '' + exit +} DEPTH=1 FOLDERS=( ) @@ -31,6 +38,7 @@ for ((i=1; i<=${#@}; i++)) { [[ "${!i}" = "--help" ]] && helpexit [[ "${!i}" = "-n" ]] && { NOCOMPRESSION=1; continue; } [[ "${!i}" = "-z" ]] && { COMPRESSION=1; continue; } + [[ "${!i}" = "-"* ]] && helpexit FOLDERS+=( "${!i%/}" ) DEPTH=0 } @@ -72,7 +80,7 @@ listfolders "${FOLDERS[@]}" | while read -r -d "" d; do done trap - 9 15 [[ "$NOCOMPRESSION" -eq 1 ]] && { - exit + exitokay } [[ "$COMPRESSION" -eq 1 ]] || { echo 'Proceed to compress? to quit' @@ -98,4 +106,4 @@ listfolders "${FOLDERS[@]}" | while read -r -d "" d; do fsize "$d.tar.gz" "$DU" echo '' done - +exitokay