From: Chris Koeritz Date: Thu, 19 Mar 2015 21:37:15 +0000 (-0400) Subject: renamed to remove dependency on current method of archiving, and cleaned some interna... X-Git-Tag: 2.140.90~692 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=b0ff12c0301f7c7bf4525c669548ae639a003ce0;p=feisty_meow.git renamed to remove dependency on current method of archiving, and cleaned some internal comments. --- diff --git a/scripts/files/squish_directories.sh b/scripts/files/squish_directories.sh new file mode 100644 index 00000000..ce2a22a3 --- /dev/null +++ b/scripts/files/squish_directories.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# archives the files / directories passed on the command line into an archive +# file tagged with a datestamp, and removes the original files / directories. +# if no names are passed to the script, then it operates on *all* directories +# under the current location. + +#hmmm: may want to revisit default behavior. + +source $FEISTY_MEOW_SCRIPTS/core/functions.sh + +dirs=() + +# snag the command line arguments into an array of names. +for i in "$@"; do dirs+=("$i"); done + +# if there were no arguments, use the current directories list of directories. +if [ ${#dirs[@]} -eq 0 ]; then + # using a temp file is clumsy but after a lot of different methods being tried, this one + # worked and wasn't super ugly. + tempfile="$(mktemp /tmp/dirlist.XXXXXX)" + find $dir -mindepth 1 -maxdepth 1 -type d -exec echo "dirs+=(\"{}\");" ';' >$tempfile + source "$tempfile" +#echo dirs default to: ${dirs[@]} + \rm -f $tempfile +fi + +# takes a directory name as an argument and sucks the directory +# into a timestamped archive file. +function flattenizer() +{ + for dirname in "$@"; do + while [[ $dirname =~ .*/$ ]]; do + dirname="${dirname:0:((${#dirname}-1))}" + done + if [ ! -z "$dirname" -a -d "$dirname" ]; then + echo "flattening '$dirname'..." + zip --symlinks -rm "${dirname}_$(date_stringer).zip" "$dirname" &>/dev/null + fi + done +} + +for ((i=0; i < ${#dirs[@]}; i++)); do + dir="${dirs[i]}" + flattenizer "$dir" +done + diff --git a/scripts/files/zip_directories.sh b/scripts/files/zip_directories.sh deleted file mode 100644 index fce35b43..00000000 --- a/scripts/files/zip_directories.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# goes through the current directory (currently) and zips up any directories -# into an archive with the same name as the directory plus a time stamp. - -source $FEISTY_MEOW_SCRIPTS/core/functions.sh - -dirs=() - -# snag the command line arguments into an array of names. -for i in "$@"; do dirs+=("$i"); done - -# if there were no arguments, use the current directories list of directories. -if [ ${#dirs[@]} -eq 0 ]; then - # using a temp file is clumsy but after a lot of different methods being tried, this one - # worked and wasn't super ugly. - tempfile="$(mktemp /tmp/dirlist.XXXXXX)" - find $dir -mindepth 1 -maxdepth 1 -type d -exec echo "dirs+=(\"{}\");" ';' >$tempfile - source "$tempfile" -#echo dirs default to: ${dirs[@]} - \rm -f $tempfile -fi - -# takes a directory name as an argument and sucks the directory -# into a timestamped zip file. -function flattenizer() -{ - for dirname in "$@"; do - while [[ $dirname =~ .*/$ ]]; do - dirname="${dirname:0:((${#dirname}-1))}" - done - if [ ! -z "$dirname" -a -d "$dirname" ]; then - echo "flattening '$dirname'..." - zip --symlinks -rm "${dirname}_$(date_stringer).zip" "$dirname" &>/dev/null - fi - done -} - -for ((i=0; i < ${#dirs[@]}; i++)); do - dir="${dirs[i]}" - flattenizer "$dir" -done -