#!/bin/bash BASE="$HOME/Desktop/AI_Brain" MISSING_LIST="$BASE/logs/missing_files.log" echo "🛠️ [heal_files] Running file system healing…" # Normalize line endings find "$BASE" -type f -exec dos2unix {} \; 2>/dev/null echo "✅ Normalized line endings" # Ensure execute bits find "$BASE" -type f -name "*.sh" -exec chmod +x {} \; echo "✅ Execute bits repaired" # Detect & rebuild zero-length files > "$MISSING_LIST" while read -r f; do if [[ ! -s "$f" ]]; then echo "⚠️ Found zero-length file: $f" | tee -a "$MISSING_LIST" echo "# Auto-rebuilt placeholder" > "$f" fi done < <(find "$BASE" -type f) # Final status if [[ -s "$MISSING_LIST" ]]; then echo "❌ Some files missing/empty – see $MISSING_LIST" else echo "✅ File system integrity OK" fi