Files
claudetools/clients/dataforth/scripts/check-dos-line-endings.ps1
Mike Swanson 5cbd49ce24 Reorganize repo: compartmentalize scripts by client/project
Move 150+ scripts from root and scripts/ into client/project directories:
- clients/dataforth/scripts/ (110 files: AD2, sync, SSH, DB, DOS scripts)
- clients/bg-builders/scripts/ (14 files: Lesley mgmt, Exchange, termination)
- clients/internal-infrastructure/scripts/ (10 files: GDAP, Gitea, backups)
- projects/msp-tools/scripts/ (9 files: CIPP, MSP onboarding, Datto)
- projects/gururmm-agent/scripts/ (3 files: API test, JWT, record counts)
- clients/glaztech/scripts/ (1 file: CentraStage removal)

Also reorganized:
- VPN scripts → infrastructure/vpn-configs/
- Retrieved API/JS files → api/
- Forum posts → projects/community-forum/forum-posts/
- SSH docs → clients/internal-infrastructure/docs/
- NWTOC/CTONW docs → projects/wrightstown-smarthome/docs/
- ACG website files → projects/internal/acg-website-2025/
- Dataforth docs → clients/dataforth/docs/
- schema-retrieved.sql → docs/database/

Deleted 24 tmp_*.ps1 one-off debug scripts (preserved in git history).
Root reduced from 220+ files to 62 items (docs + directories only).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 17:15:07 -07:00

87 lines
2.9 KiB
PowerShell

# Check and fix DOS line endings for batch files
Write-Host "=== Checking DOS Batch File Line Endings ===" -ForegroundColor Cyan
Write-Host ""
# Find all .bat files (excluding git/node_modules)
$batFiles = Get-ChildItem -Recurse -Filter "*.bat" | Where-Object {
$_.FullName -notlike "*\.git\*" -and
$_.FullName -notlike "*\node_modules\*"
}
Write-Host "Found $($batFiles.Count) batch files to check:" -ForegroundColor Yellow
Write-Host ""
$needsConversion = @()
foreach ($file in $batFiles) {
$bytes = [System.IO.File]::ReadAllBytes($file.FullName)
$hasCRLF = $false
$hasLF = $false
for ($i = 0; $i -lt $bytes.Length - 1; $i++) {
if ($bytes[$i] -eq 13 -and $bytes[$i+1] -eq 10) {
# Found CRLF (0x0D 0x0A)
$hasCRLF = $true
break
}
if ($bytes[$i] -eq 10 -and ($i -eq 0 -or $bytes[$i-1] -ne 13)) {
# Found LF without CR
$hasLF = $true
break
}
}
$relativePath = $file.FullName.Replace((Get-Location).Path + "\", "")
if ($hasCRLF) {
Write-Host "[OK] $relativePath" -ForegroundColor Green
Write-Host " CRLF (DOS format)" -ForegroundColor Gray
} elseif ($hasLF) {
Write-Host "[FAIL] $relativePath" -ForegroundColor Red
Write-Host " LF only (Unix format) - NEEDS CONVERSION" -ForegroundColor Red
$needsConversion += $file
} else {
Write-Host "[INFO] $relativePath" -ForegroundColor Yellow
Write-Host " No line endings detected (empty or single line)" -ForegroundColor Gray
}
Write-Host ""
}
if ($needsConversion.Count -gt 0) {
Write-Host "=== Files Needing Conversion: $($needsConversion.Count) ===" -ForegroundColor Red
Write-Host ""
foreach ($file in $needsConversion) {
Write-Host " - $($file.Name)" -ForegroundColor Red
}
Write-Host ""
Write-Host "Convert to DOS format? (Y/N)" -ForegroundColor Yellow
$response = Read-Host
if ($response -eq 'Y' -or $response -eq 'y') {
Write-Host ""
Write-Host "Converting files..." -ForegroundColor Yellow
foreach ($file in $needsConversion) {
try {
$content = Get-Content $file.FullName -Raw
$dosContent = $content -replace "`r?`n", "`r`n"
[System.IO.File]::WriteAllText($file.FullName, $dosContent, [System.Text.Encoding]::ASCII)
Write-Host " [OK] $($file.Name)" -ForegroundColor Green
} catch {
Write-Host " [ERROR] $($file.Name): $($_.Exception.Message)" -ForegroundColor Red
}
}
Write-Host ""
Write-Host "=== Conversion Complete ===" -ForegroundColor Green
} else {
Write-Host ""
Write-Host "Conversion skipped." -ForegroundColor Yellow
}
} else {
Write-Host "=== All Files OK ===" -ForegroundColor Green
Write-Host "All batch files have proper DOS (CRLF) line endings." -ForegroundColor Green
}