-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSuffixesToUpper.ps1
49 lines (45 loc) · 1.18 KB
/
SuffixesToUpper.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
37
38
39
40
41
42
43
44
45
46
47
48
49
param (
[string]$FileMask = '*.tst',
[switch]$Recurse
)
if ($Recurse)
{
$filesToProcess = Get-ChildItem $FileMask -Recurse
}
else
{
$filesToProcess = Get-ChildItem $FileMask
}
foreach ($sf in $filesToProcess)
{
$hitCount = 1
while ($hitCount -gt 0)
{
$hitCount = 0
$sfContent = Get-Content $sf
Out-File -FilePath $sf.FullName -Force
foreach ($line in $sfContent)
{
if ($line -cmatch '(^.*)(:[a-z])(.*$)')
{
$hitCount++
$ogLine = $Matches[0]
$line = "$($Matches[1])$($Matches[2].ToUpper())$($Matches[3])"
Write-Output -inputObject "$($sf.Name) regex hit : $($ogLine)"
Write-Output -inputObject "$($sf.Name) replacement: $($line)"
Write-Output -inputObject " "
}
Add-Content -LiteralPath $sf.FullName -Value $line
}
}
# try
# {
# Write-Output "$($sf.Name) written successfully"
# Write-Output -inputObject " "
# }
# catch
# {
# Write-Output "$($sf.Name) Error when writing!"
# Write-Output -inputObject " "
# }
}