34 lines
1.7 KiB
PowerShell
34 lines
1.7 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
$extensions = @("*.java", "*.xml", "*.yml", "*.properties", "*.gradle", "*.md", "Dockerfile*")
|
|
$baseDir = "C:\eGovFrameDev-4.3.1-64bit\workspace-egov\axhub-backend-main"
|
|
|
|
Write-Host "Replacing text..."
|
|
Get-ChildItem -Path $baseDir -Include $extensions -Recurse -File | ForEach-Object {
|
|
if ($_.FullName -notmatch "\\build\\" -and $_.FullName -notmatch "\\\.git\\" -and $_.FullName -notmatch "\\\.gradle\\" -and $_.FullName -notmatch "\\bin\\") {
|
|
try {
|
|
$content = Get-Content $_.FullName -Raw -Encoding UTF8
|
|
$newContent = $content -replace "dapms", "mcg"
|
|
$newContent = $newContent -replace "dapmt", "mcc"
|
|
if ($content -cne $newContent) {
|
|
Write-Host "Updated text in: $($_.FullName)"
|
|
$utf8NoBom = New-Object System.Text.UTF8Encoding $False
|
|
[System.IO.File]::WriteAllText($_.FullName, $newContent, $utf8NoBom)
|
|
}
|
|
} catch {
|
|
Write-Host "Skipped binary or locked file: $($_.FullName)"
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host "Renaming directories..."
|
|
Get-ChildItem -Path $baseDir -Recurse -Directory | Where-Object { $_.Name -eq "dapms" -or $_.Name -eq "dapmt" } | Sort-Object -Property @{Expression={$_.FullName.Length}; Descending=$true} | ForEach-Object {
|
|
if ($_.FullName -notmatch "\\build\\" -and $_.FullName -notmatch "\\\.git\\" -and $_.FullName -notmatch "\\\.gradle\\" -and $_.FullName -notmatch "\\bin\\") {
|
|
$newName = if ($_.Name -eq "dapms") { "mcg" } else { "mcc" }
|
|
Write-Host "Renaming dir: $($_.FullName) -> $newName"
|
|
Rename-Item -Path $_.FullName -NewName $newName
|
|
}
|
|
}
|
|
|
|
Write-Host "Refactoring completed!"
|