1d1e138c3f503d5f559c0eca522661bad0e51e4a
[feisty_meow.git] / scripts / files / cleanerator.sh
1 #!/bin/bash
2
3 cleaning_dirs=($*)
4
5 more_authoritative=( ~/feisty_meow ~/scavenging_inova/inovasoft )
6 ###not yet ~/scavenging_inova/lightlink 
7
8 if [ -z "$TMP" ]; then TMP=/tmp; fi
9
10 # we generate the full directory list for the authoritative places into here.
11 zesty_authoritative_dirs=$(mktemp $TMP/cleanerator_authority.XXXXXX)
12 # we also make a list of all the directories under our cleaning locations here.
13 perky_scrubbing_dirs=$(mktemp $TMP/cleanerator_scrubbinz.XXXXXX)
14
15 # dump out the directories found in the authoritative areas.
16 for i in "${more_authoritative[@]}"; do
17   real_dir="$(\cd "$i" && \pwd)"
18   find "$real_dir" -type d | grep -v "\.svn" | grep -v "\.git" >>"$zesty_authoritative_dirs"
19 done
20
21 # now go to all of our places to clean, find all directories under them,
22 # and add them to our big list of places to scrub.
23 for i in "${cleaning_dirs[@]}"; do
24   real_dir="$(\cd "$i" && \pwd)"
25   find "$real_dir" -depth -type d | grep -v "\.svn" | grep -v "\.git" >>"$perky_scrubbing_dirs"
26 done
27
28 # load all the names from our files and do a massive N x M size loop.
29 while read i; do
30 #  echo "cleaning: $i"
31   pushd "$i" &>/dev/null
32 #pwd
33   while read j; do 
34 #    echo "against authority: $j"
35     # try to clean it out of source control first.
36     bash ~/feisty_meow/scripts/rev_control/svn_rm_dupes.sh "$j" "$i"
37     # if that doesn't work, just whack it.
38     bash ~/feisty_meow/scripts/files/whack_dupes.sh "$j" "$i"
39   done <"$zesty_authoritative_dirs"
40   popd &>/dev/null
41 done <"$perky_scrubbing_dirs"
42
43 # clean up afterwards.
44 rm -f "$zesty_authoritative_dirs"
45 rm -f "$perky_scrubbing_dirs"
46