generated from SU-SWS/stanford_starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrename_theme.sh
More file actions
executable file
·37 lines (26 loc) · 879 Bytes
/
rename_theme.sh
File metadata and controls
executable file
·37 lines (26 loc) · 879 Bytes
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
36
#/bin/bash
# This script will rename the theme from stanford_starter to your custom theme name.
function renameFilesRecursively () {
SEARCH="$1"
REPLACE="$2"
find ./ -type f -name "*${SEARCH}*" | while read FILENAME ; do
NEW_FILENAME="$(echo ${FILENAME} | sed -e "s/${SEARCH}/${REPLACE}/g")";
mv "${FILENAME}" "${NEW_FILENAME}";
done
}
read -p 'New theme name: ' NEW_NAME
REGEX='^[[:upper:]]-([0-9]{2}|[0-9]{3})-([0-9]{2}|[0-9]{3})$'
if [ -z "$NEW_NAME" ]
then
echo 'Inputs cannot be blank please try again'
exit 0
fi
# Check if the input is only letters.
if ! [[ "$NEW_NAME" =~ ^[a-z0-9_]+$ ]]
then
echo "Invalid theme name."
exit 0
fi
find . -type f -not -path "./.git/*" -not -path "./node_modules/*" -exec sed -i "s/stanford_starter/$NEW_NAME/g" {} + &&
renameFilesRecursively "stanford_starter" $NEW_NAME;
rm ./rename_theme.sh