aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/rename-project.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/rename-project.sh b/tools/rename-project.sh
new file mode 100755
index 0000000..eeb4e76
--- /dev/null
+++ b/tools/rename-project.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+if [ -z "$1" ]; then
+ echo "No name supplied!"
+ exit
+fi
+
+# Defaults
+original_name="ExamTemplate"
+new_name="$1"
+
+if [ ! -z "$2" ]; then
+ original_name="$1"
+ new_name="$2"
+fi
+
+rename () {
+ for file in $@; do
+ mv $file ${file/$original_name/$new_name}
+ done
+}
+
+# Rename all directories and then files
+rename $(find ../ -type d -name "*$original_name*")
+rename $(find ../ -type f -name "*$original_name*")
+
+# Rename all occurences inside files
+find ../ -type f -not -path "../tools/*" -print0 | xargs -0 sed -i "s/$original_name/$new_name/g"
+
+# The database context is named TemplateContext by default
+# A third paramter should never be given, the second check is to prevent stack overflow
+# if someone wants to name their project just "Template"
+if [ "$original_name" != "Template" ] && [ "$3" != "Recursive" ]; then
+ ./rename-project.sh "Template" $new_name "Recursive"
+fi