blob: 876432f004a655490c322757f81acf0b720e3525 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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/*" -not -path "../.git/*" -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
|