forked from erkle64/FoundryCommands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDoRename.ps1
36 lines (28 loc) · 1.67 KB
/
DoRename.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$startname = "UnfoundryStart"
$cpath = Get-Location
$modname = Split-Path -Path $cpath -leaf
$startauthor = "erkle64"
$author = Read-Host -Prompt 'Enter author name'
$title = "Renaming from '$startname' to '$modname'"
$question = 'Are you sure you want to proceed?'
$choices = '&Yes', '&No'
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
if ($decision -eq 0) {
Write-Host "Renaming folders"
Rename-Item -Path .\$startname -NewName $modname
Write-Host "Renaming files"
Rename-Item -Path .\$startname.sln -NewName "$modname.sln"
Rename-Item -Path .\$modname\$startname.csproj -NewName "$modname.csproj"
Write-Host "Search and replace"
((Get-Content -path .\$modname.sln -Raw) -replace $startname,$modname) | Set-Content -Path .\$modname.sln
((Get-Content -path .\Foundry.props -Raw) -replace $startname,$modname) | Set-Content -Path .\Foundry.props
((Get-Content -path .\$modname\Plugin.cs -Raw) -replace $startauthor,$author) | Set-Content -Path .\$modname\Plugin.cs
((Get-Content -path .\$modname\Plugin.cs -Raw) -replace $startname,$modname) | Set-Content -Path .\$modname\Plugin.cs
((Get-Content -path .\Mod\modInfo.json -Raw) -replace $startauthor,$author) | Set-Content -Path .\Mod\modInfo.json
((Get-Content -path .\Mod\modInfo.json -Raw) -replace $startname,$modname) | Set-Content -Path .\Mod\modInfo.json
((Get-Content -path .\$modname\$modname.csproj -Raw) -replace $startname,$modname) | Set-Content -Path .\$modname\$modname.csproj
((Get-Content -path .\$modname\Properties\AssemblyInfo.cs -Raw) -replace $startname,$modname) | Set-Content -Path .\$modname\Properties\AssemblyInfo.cs
Write-Host "Done"
Read-Host "Press enter key to exit"
}
Exit 0