3 #smoove_lists source target
5 #takes the contents one level deep in the directories in source
6 #and stuffs them into similarly named directory in target.
7 #the directoy under target is named after the last directory
8 #component in each source directory name.
10 # smoovelists ~/notes_pending ~/list_archive
11 #would move all the files in the directories under notes_pending into
12 #similar directories under list_archive.
13 #so, a file ~/notes_pending/foolio/moopter.txt would get moved over to
14 #a directory called ~/list_archive/moopter.txt
16 #this is useful for coalescing a subset of some to-do items that are under
17 #directories in a temporary folder into the main archive of to-dos.
18 #otherwise one must do some manual labor to collapse the directories into
20 #it only supports one level deep of directories currently because that's
21 #the most common usage.
24 echo smoove_lists: this requires a source directory where a bunch of list
25 echo directories are located and a target where similarly named directories
26 echo exist. the files in the source will be moved over to the target.
30 source="$(pushd "$1" &>/dev/null; pwd; popd &>/dev/null)"
31 target="$(pushd "$2" &>/dev/null; pwd; popd &>/dev/null)"
33 #echo source is $source
34 #echo target is $target
36 # create the same directory names under the target if they aren't already
38 pushd "$source" &>/dev/null
40 tempfile="$(mktemp "$TMP/zz_smoove.XXXXXX")"
42 find . -maxdepth 1 -mindepth 1 -type d >"$tempfile"
44 # make a corresponding directory if there isn't one yet.
45 if [ ! -d "$target/$found" ]; then
46 mkdir "$target/$found"
48 # move all the files out of the source and into the target.
49 mv "$found"/* "$target/$found/"
54 # clean out any directories that we managed to move everything out of.
55 perl "$FEISTY_MEOW_SCRIPTS/files/zapdirs.pl" $source