From: Chris Koeritz Date: Mon, 27 Aug 2012 19:25:09 +0000 (-0400) Subject: fixed for names with spaces, nice approach doesn't need xargs and never shells out X-Git-Tag: 2.140.90~1263 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=0fde3c23ef41308e9fe25fc390b467f8e51bc0ce;p=feisty_meow.git fixed for names with spaces, nice approach doesn't need xargs and never shells out after the initial find. --- diff --git a/scripts/files/zip_directories.sh b/scripts/files/zip_directories.sh index 1b5e5d01..9b5daed4 100644 --- a/scripts/files/zip_directories.sh +++ b/scripts/files/zip_directories.sh @@ -5,7 +5,18 @@ source $FEISTY_MEOW_SCRIPTS/core/functions.sh -#hmmm: take a dir to go to for this. +#hmmm: take a dir parameter to go to for this. dir=. -for i in $(find $dir -mindepth 1 -maxdepth 1 -type d) ; do zip -rm "${i}_$(date_stringer)" "$i"; done +function flattenizer() +{ + while read dirname; do + if [ ! -z "$dirname" ]; then + echo "flattening dir name is '$dirname'..." + zip -rm "${dirname}_$(date_stringer)" "$dirname" &>/dev/null + fi + done +} + +find $dir -mindepth 1 -maxdepth 1 -type d | flattenizer +