3 # archives the files / directories passed on the command line into an archive
4 # file tagged with a datestamp, and removes the original files / directories.
5 # if no names are passed to the script, then it operates on *all* directories
6 # under the current location.
8 #hmmm: may want to revisit default behavior.
10 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
14 # snag the command line arguments into an array of names.
15 for i in "$@"; do dirs+=("$i"); done
17 # if there were no arguments, use the current directories list of directories.
18 if [ ${#dirs[@]} -eq 0 ]; then
19 # using a temp file is clumsy but after a lot of different methods being tried, this one
20 # worked and wasn't super ugly.
21 tempfile="$(mktemp /tmp/dirlist.XXXXXX)"
22 find $dir -mindepth 1 -maxdepth 1 -type d -exec echo "dirs+=(\"{}\");" ';' >$tempfile
24 #echo dirs default to: ${dirs[@]}
28 # takes a directory name as an argument and sucks the directory
29 # into a timestamped archive file.
30 function flattenizer()
32 for dirname in "$@"; do
33 while [[ $dirname =~ .*/$ ]]; do
34 dirname="${dirname:0:((${#dirname}-1))}"
36 if [ ! -z "$dirname" -a -d "$dirname" ]; then
37 echo "flattening '$dirname'..."
38 zip --symlinks -rm "${dirname}_squished_on_$(hostname)_at_$(date_stringer).zip" "$dirname" &>/dev/null
43 for ((i=0; i < ${#dirs[@]}; i++)); do