From d19738fff4ec89e5e1940b8ef8b2c74a6080d1ba Mon Sep 17 00:00:00 2001
From: rdrew <rdrew@upei.ca>
Date: Fri, 21 Mar 2025 11:34:08 -0300
Subject: [PATCH] [nb] Edit: Olivero Sub-theme commands.md

---
 Olivero Sub-theme commands.md | 81 +++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/Olivero Sub-theme commands.md b/Olivero Sub-theme commands.md
index 21b12e5..849f1d5 100644
--- a/Olivero Sub-theme commands.md	
+++ b/Olivero Sub-theme commands.md	
@@ -38,3 +38,84 @@ copy these files back into the sync folder and run:
 
 *Manually configure the Display contexts so the viewers are placed in the new theme
 
+<!--Below is a bask script that will copy a theme dir and rename all files in and out:-->
+#!/bin/bash
+
+# Prompt for source directory
+read -p "Enter the source directory path: " SOURCE_DIR
+
+# Check if source directory exists
+if [ ! -d "$SOURCE_DIR" ]; then
+    echo "Error: Source directory '$SOURCE_DIR' does not exist."
+    exit 1
+fi
+
+# Prompt for new directory name
+read -p "Enter the new directory name: " NEW_DIR
+
+# Prompt for old theme name to replace
+read -p "Enter the old theme name to replace: " OLD_THEME
+
+# Prompt for new theme name
+read -p "Enter the new theme name: " NEW_THEME
+
+# Extract the parent directory from SOURCE_DIR to place the new directory there
+PARENT_DIR=$(dirname "$SOURCE_DIR")
+NEW_PATH="$PARENT_DIR/$NEW_DIR"
+
+# Check if new directory already exists
+if [ -d "$NEW_PATH" ]; then
+    echo "Error: Directory '$NEW_PATH' already exists."
+    exit 1
+fi
+
+# Copy the source directory to the new directory
+echo "Copying '$SOURCE_DIR' to '$NEW_PATH'..."
+cp -r "$SOURCE_DIR" "$NEW_PATH"
+
+if [ $? -ne 0 ]; then
+    echo "Error: Failed to copy the directory."
+    exit 1
+fi
+
+# Change to the new directory
+cd "$NEW_PATH" || exit 1
+
+# Generate case variations of OLD_THEME and NEW_THEME
+OLD_THEME_LOWER=$(echo "$OLD_THEME" | tr '[:upper:]' '[:lower:]')
+OLD_THEME_UPPER=$(echo "$OLD_THEME" | tr '[:lower:]' '[:upper:]')
+OLD_THEME_FIRSTCAP=$(echo "$OLD_THEME" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')
+
+NEW_THEME_LOWER=$(echo "$NEW_THEME" | tr '[:upper:]' '[:lower:]')
+NEW_THEME_UPPER=$(echo "$NEW_THEME" | tr '[:lower:]' '[:upper:]')
+NEW_THEME_FIRSTCAP=$(echo "$NEW_THEME" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')
+
+# Escape special characters for sed
+OLD_THEME_LOWER_ESC=$(echo "$OLD_THEME_LOWER" | sed 's/[\/&]/\\&/g')
+OLD_THEME_UPPER_ESC=$(echo "$OLD_THEME_UPPER" | sed 's/[\/&]/\\&/g')
+OLD_THEME_FIRSTCAP_ESC=$(echo "$OLD_THEME_FIRSTCAP" | sed 's/[\/&]/\\&/g')
+
+NEW_THEME_LOWER_ESC=$(echo "$NEW_THEME_LOWER" | sed 's/[\/&]/\\&/g')
+NEW_THEME_UPPER_ESC=$(echo "$NEW_THEME_UPPER" | sed 's/[\/&]/\\&/g')
+NEW_THEME_FIRSTCAP_ESC=$(echo "$NEW_THEME_FIRSTCAP" | sed 's/[\/&]/\\&/g')
+
+echo "Matching: '$OLD_THEME_LOWER' → '$NEW_THEME_LOWER', '$OLD_THEME_UPPER' → '$NEW_THEME_UPPER', '$OLD_THEME_FIRSTCAP' → '$NEW_THEME_FIRSTCAP'"
+
+# Rename files by replacing each case variation of OLD_THEME with corresponding NEW_THEME
+echo "Renaming files..."
+find . -type f \( -name "*$OLD_THEME_LOWER*" -o -name "*$OLD_THEME_UPPER*" -o -name "*$OLD_THEME_FIRSTCAP*" \) | while IFS= read -r file; do
+    new_file=$(echo "$file" | sed "s/$OLD_THEME_LOWER_ESC/$NEW_THEME_LOWER_ESC/g; s/$OLD_THEME_UPPER_ESC/$NEW_THEME_UPPER_ESC/g; s/$OLD_THEME_FIRSTCAP_ESC/$NEW_THEME_FIRSTCAP_ESC/g")
+    if [ "$file" != "$new_file" ]; then
+        mv -v "$file" "$new_file"
+    fi
+done
+
+# Replace each case variation of OLD_THEME with corresponding NEW_THEME in file contents
+echo "Replacing in file contents..."
+find . -type f -exec sed -i '' -e "s/$OLD_THEME_LOWER_ESC/$NEW_THEME_LOWER_ESC/g" -e "s/$OLD_THEME_UPPER_ESC/$NEW_THEME_UPPER_ESC/g" -e "s/$OLD_THEME_FIRSTCAP_ESC/$NEW_THEME_FIRSTCAP_ESC/g" {} \;
+
+echo "Directory copied, files renamed, and contents updated successfully!"
+echo "New directory: '$NEW_PATH'"
+
+
+