diff --git a/src/main/webapp/static/themes/compiletheme.sh b/src/main/webapp/static/themes/compiletheme.sh
index 7dea436a886d571a8271c3fcfb12b0525063e059..c6c5164f862974404e4ab5728370b2d2e3b97f1f 100755
--- a/src/main/webapp/static/themes/compiletheme.sh
+++ b/src/main/webapp/static/themes/compiletheme.sh
@@ -7,21 +7,43 @@
 # In the case it does not compile all files, it's helpful to delete the sass-cache (rm -r .sass-cache).
 #
 # usage:
-# ./compiletheme.sh									# compile themes in the current directory
-# ./compiletheme.sh /path/to/your/custom/theme		# compile themes in the given directory
+# ./compiletheme.sh										# compile themes in the current directory
+# ./compiletheme.sh /path/to/your/custom/theme			# compile themes in the given directory
+# ./compiletheme.sh /path/to/your/custom/themedir		# compile all themes in the given directory
 #
 ####
 
-style=compressed
-#style=compact
+# Configuration
+STYLE=compressed
+#STYLE=compact
 
-# default to compile the themes in the current directory
-directory="."
-if [ ! -z $1  ]; then directory=$1; fi
+# Helper method to add theme to array
+searchThemes () {
+	if [ ! -z $1  ];
+	then
+	    if [ -f $1/layout.scss  ];
+	    then
+	    	doCompile $1
+	    elif [ -d $1  ];
+	    then
+			for FILE in $1/*
+			do
+				searchThemes $FILE
+			done
+		fi
+	fi
+}
 
-echo "Compiling SASS: $directory $style"
-sass --version
+# Helper method to compile the theme
+doCompile () {
+	echo "Compiling SASS: $1 $STYLE"
+	sass --version
+	sass --style $STYLE --update $1:$1 --load-path openolat openolat/all openolat/all/modules openolat/print openolat/mobile
+	echo "done"
+}
 
-sass --style $style --update $directory:$directory --load-path openolat openolat/all openolat/all/modules openolat/print openolat/mobile
 
-echo "done"
\ No newline at end of file
+# Add themes to compile from given path
+doCompile ".";
+searchThemes $1;
+echo "DONE"