Index: other-projects/nightly-tasks/diffcol/trunk/gen-model-colls.sh
===================================================================
--- other-projects/nightly-tasks/diffcol/trunk/gen-model-colls.sh	(revision 28045)
+++ other-projects/nightly-tasks/diffcol/trunk/gen-model-colls.sh	(revision 28046)
@@ -77,4 +77,7 @@
 	return;
     fi
+
+# return here if just deleting empty dirs
+#return
 
     # diff the svn model and rebuilt model collections
@@ -117,10 +120,18 @@
 
     # Now svn remove what's unique to model-collect and svn add what's been rebuilt in index and archives
-    # see # http://stackoverflow.com/questions/7502261/delete-folder-content-and-remove-from-version-control
- 
+    # see http://stackoverflow.com/questions/7502261/delete-folder-content-and-remove-from-version-control
+    # And doing: rm -rfv mydir/* should leave .hidden folders in mydir, see
+    # http://askubuntu.com/questions/72446/how-to-remove-all-files-and-subdirectories-in-a-directory-without-deleting-the-d
     if [ "$mode" == "svndelete" ]; then
 	svn rm model-collect/$collection/archives/*
 	svn rm model-collect/$collection/index/*
-    fi
+#	rm -rfv model-collect/$collection/archives/*
+#	rm -rfv model-collect/$collection/index/*	
+	# from testing, the above will remove all the contents of archives and index 
+	# except the .svn folder of toplevel archives/index
+    fi
+
+    # http://stackoverflow.com/questions/5044214/how-do-i-detect-and-or-delete-empty-subversion-directories
+    # http://stackoverflow.com/questions/1301203/removing-svn-files-from-all-directories
 
     # copy across the contents of the rebuilt model-collection's index and archives to the svn model-collect
@@ -139,7 +150,6 @@
 
     # if etc/collect.cfg is different, copy it across too?
-
-
 }
+
 
 # re-build a single collection in "collect" which is a copy of model-collect
@@ -152,4 +162,31 @@
     #get just the basename
     collection=`basename $collection`
+
+    # clean up empty directories:
+    # HASH dirs that are empty in local (non-svn) collect's archives and index/assoc, 
+    # need to be removed from the svn in model-collect. 
+    # They're almost empty in the mode-collect, except for the .svn folder they contain
+
+    for coldir in `find collect/$collection/archives/HASH* -type d -empty`; do
+	modeldir="model-$coldir"
+	echo "Removing empty dir from svn: $modeldir"
+	
+	# remove from svn of model collect
+	svn rm $modeldir
+	rm -rf $modeldir
+	# remove physically from local collect (not necessary, as a rebuild will sort this out too)
+	rm -rf $coldir
+    done
+
+    for coldir in `find collect/$collection/index/assoc/HASH* -type d -empty`; do
+	modeldir="model-$coldir"
+	echo "Removing empty dir from svn: $modeldir"
+	
+	# remove from svn of model collect
+	svn rm $modeldir
+	rm -rf $modeldir
+	# remove physically from local collect (not necessary, as a rebuild will sort this out too)
+	rm -rf $coldir
+    done
     
     import.pl -removeold $collection
@@ -304,4 +341,8 @@
 
 
+# Now delete all empty dirs in the copy of model-collect (since the dirs will not have .svn folders in them anymore)
+# http://www.commandlinefu.com/commands/view/5131/recursively-remove-all-empty-directories
+#find collect -type d -empty -delete
+
 # Set up the Greenstone environment for building
 source setup.bash
@@ -317,4 +358,8 @@
 	single_collection $collection;
 	if [ "x$mode" != "x" ]; then
+	    # Now delete all empty dirs in the copy of model-collect (since the dirs will not have .svn folders in them anymore)
+            # http://www.commandlinefu.com/commands/view/5131/recursively-remove-all-empty-directories
+#	    find collect/$collection/archives/HASH* -type d -empty -delete
+#	    find collect/$collection/index/assoc/HASH* -type d -empty -delete
 	    update_single_collection $collection $mode;
 	fi
@@ -329,4 +374,6 @@
 	    single_collection $collection;
 	    if [ "x$mode" != "x" ]; then
+#		find collect/$collection/archives/HASH* -type d -empty -delete
+#		find collect/$collection/index/assoc/HASH* -type d -empty -delete
 		update_single_collection $collection $mode;
 	    fi
@@ -358,2 +405,38 @@
 
 
+# The following in a separate script file will delete all folders from model-collect that are
+# empty in the copied collection (all folders which contain only a .svn subfolder in model-collect)
+
+#for collection in collect/*; do
+    #escape the filename (in case of space)
+#    collection=`echo $collection | sed 's@ @\\\ @g'`
+    
+    #get just the basename
+#    collection=`basename $collection`
+
+    # HASH dirs that are empty in local collect's archives and index/assoc, 
+    # need to be removed from the svn in model-collect
+
+#    for line in `find collect/$collection/archives/HASH* -type d -empty`; do
+#	modelline="model-$line"
+#	echo "LINE: $modelline"
+	
+	# remove from svn of model collect
+#	svn rm $modelline
+##	rm -rf $modelline
+	# remove physically from local collect
+#	rm -rf $line
+#    done
+
+#    for line in `find collect/$collection/index/assoc/HASH* -type d -empty`; do
+#	modelline="model-$line"
+#	echo "LINE: $modelline"
+	
+	# remove from svn of model collect
+#	svn rm $modelline
+##	rm -rf $modelline
+	# remove physically from local collect
+#	rm -rf $line
+#    done
+
+#done
