Adding all files and folders

This commit is contained in:
2026-02-01 12:08:31 +11:00
parent 892f3f2418
commit 1fb54400b4
24 changed files with 63803 additions and 0 deletions

View File

@@ -0,0 +1,146 @@
#!/bin/bash
# -- Configuration ---
LOG_FILE="logs/03_find_and_sync_data.log"
DRY_RUN=""
SOURCE_WIN_DRIVE="/media/sam/8294CD2994CD2111"
TARGET_DATA_DIR="/data"
# Check for --dry-run flag
if [ "$1" == "--dry-run" ]; then
DRY_RUN="--dry-run"
echo "--- PERFORMING DRY RUN ---" | tee -a "$LOG_FILE"
fi
# Helper function for logging
log() {
echo "$1" | tee -a "$LOG_FILE"
}
run_rsync_dry_run() {
local source_path="$1"
local target_path="$2"
local descriptive_name="$3"
log "------------------------------------------------------------------------"
log "Preparing to sync: $descriptive_name"
log "Source: $source_path"
log "Target: $target_path"
log "------------------------------------------------------------------------"
# Ensure target directory exists for rsync
if [ ! -d "$target_path" ]; then
log "Creating target directory: $target_path"
if [ -z "$DRY_RUN" ]; then
mkdir -p "$target_path"
fi
fi
# Use rsync -a (archive mode) for comprehensive copying, and -n for dry run.
# The trailing slash on source_path copies contents, not the directory itself.
rsync -avh --info=progress2 $DRY_RUN "${source_path}/" "${target_path}/" 2>&1 | tee -a "$LOG_FILE"
log "Finished dry run for $descriptive_name."
}
# Initialize log file
echo "Data Discovery and Sync Log - $(date)" > "$LOG_FILE"
echo "----------------------------------------------------" >> "$LOG_FILE"
if [ -n "$DRY_RUN" ]; then
log "Dry run mode enabled. No files will be changed."
fi
log "Source Windows Drive: $SOURCE_WIN_DRIVE"
log "Target Data Directory: $TARGET_DATA_DIR"
log ""
# --- Mapping Configuration (Source on Windows Drive -> Target in /data) ---
# Each entry is: "source_path" "target_subdirectory_in_data" "descriptive_name"
# Personal Documents, Pictures, Music, Videos
declare -a PERSONAL_FOLDERS=(
"Users/sam/Documents" "personal/Documents" "Personal Documents"
"Users/sam/Pictures" "personal/Pictures" "Personal Pictures"
"Users/sam/Music" "personal/Music" "Personal Music"
"Users/sam/Videos" "personal/Videos" "Personal Videos"
"Users/sam/Downloads" "personal/Downloads" "Personal Downloads"
)
# Web/Work Projects
declare -a WORK_PROJECTS=(
"xampp/htdocs" "work/htdocs" "XAMPP htdocs projects"
"frei0r" "work/frei0r" "Frei0r Projects"
# Add other common workspace/project folders here if known
# e.g., "Users/sam/workspace" "work/workspace" "General Workspaces"
)
# IoT Projects
declare -a IOT_PROJECTS=(
"Arduino" "iot/Arduino" "Arduino Projects" # Assuming there's an Arduino folder
)
# Generic project folders to search for
declare -a GENERIC_PROJECT_NAMES=(
"Projects"
"Code"
"Dev"
)
# --- Execute mappings ---
log "--- Processing Personal Folders ---"
for ((i=0; i<${#PERSONAL_FOLDERS[@]}; i+=3)); do
SOURCE="${SOURCE_WIN_DRIVE}/${PERSONAL_FOLDERS[i]}"
TARGET="${TARGET_DATA_DIR}/${PERSONAL_FOLDERS[i+1]}"
DESC="${PERSONAL_FOLDERS[i+2]}"
if [ -d "$SOURCE" ]; then
run_rsync_dry_run "$SOURCE" "$TARGET" "$DESC"
else
log "WARNING: Source directory not found: $SOURCE"
fi
done
log ""
log "--- Processing Work Projects ---"
for ((i=0; i<${#WORK_PROJECTS[@]}; i+=3)); do
SOURCE="${SOURCE_WIN_DRIVE}/${WORK_PROJECTS[i]}"
TARGET="${TARGET_DATA_DIR}/${WORK_PROJECTS[i+1]}"
DESC="${WORK_PROJECTS[i+2]}"
if [ -d "$SOURCE" ]; then
run_rsync_dry_run "$SOURCE" "$TARGET" "$DESC"
else
log "WARNING: Source directory not found: $SOURCE"
fi
done
log ""
log "--- Processing IoT Projects ---"
for ((i=0; i<${#IOT_PROJECTS[@]}; i+=3)); do
SOURCE="${SOURCE_WIN_DRIVE}/${IOT_PROJECTS[i]}"
TARGET="${TARGET_DATA_DIR}/${IOT_PROJECTS[i+1]}"
DESC="${IOT_PROJECTS[i+2]}"
if [ -d "$SOURCE" ]; then
run_rsync_dry_run "$SOURCE" "$TARGET" "$DESC"
else
log "WARNING: Source directory not found: $SOURCE"
fi
done
log ""
log "--- Searching for Generic Project Folders ---"
# This section tries to find common project-like folders directly under the Windows user profile
# and prompts the user for action. For automation, we'll try to guess.
# For now, we'll just list them to avoid making assumptions without user confirmation.
log "Searching for additional project-like folders under ${SOURCE_WIN_DRIVE}/Users/sam/ and similar paths:"
find "${SOURCE_WIN_DRIVE}/Users/sam" -maxdepth 3 -type d \( -name "Projects" -o -name "Code" -o -name "Dev" -o -name "*workspace*" -o -name "*repos*" \) 2>/dev/null | while read -r found_dir; do
log "Found potential project directory: $found_dir"
# In a real interactive session, we'd ask the user where to put this.
# For now, we just log its existence.
done
log ""
log "--- Data discovery and dry run finished. ---"
log "Please review the log file: $LOG_FILE"
log "If the output looks correct, run this script again with '--live' (or no flag) to perform the actual copy."
log "Example: scripts/03_find_and_sync_data.sh"