fixed for names with spaces, nice approach doesn't need xargs and never shells out
authorChris Koeritz <fred@gruntose.com>
Mon, 27 Aug 2012 19:25:09 +0000 (15:25 -0400)
committerChris Koeritz <fred@gruntose.com>
Mon, 27 Aug 2012 19:25:09 +0000 (15:25 -0400)
after the initial find.

scripts/files/zip_directories.sh

index 1b5e5d014a592dc4b6519fdafc6fda67a5c0fad4..9b5daed437275add6838c25382149038618a86f6 100644 (file)
@@ -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
+