From 0fde3c23ef41308e9fe25fc390b467f8e51bc0ce Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Mon, 27 Aug 2012 15:25:09 -0400 Subject: [PATCH] fixed for names with spaces, nice approach doesn't need xargs and never shells out after the initial find. --- scripts/files/zip_directories.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 + -- 2.34.1