-
Notifications
You must be signed in to change notification settings - Fork 21
/
update-openatv.ps1
47 lines (39 loc) · 1.53 KB
/
update-openatv.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
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
function Manipulate-TextFile {
param(
[string]$filePath,
[ref]$countChanged,
[ref]$unchangedLines
)
if (Test-Path $filePath -PathType Leaf) {
$fileContent = Get-Content $filePath
$modifiedContent = @()
$changed = $false
foreach ($line in $fileContent) {
$modifiedContent += $line
if ($line -match 'OpenATV_7\.4_E2|"openATV 7\.4 enigma2"|OpenATV_7\.4_enigma2') {
$modifiedContent += $line -replace '7\.4', '7.5'
$changed = $true
}
}
if ($changed) {
$countChanged.Value++
$modifiedContent | Set-Content $filePath
Write-Host "Text manipulation completed in $filePath"
} else {
$unchangedLines.Value += "`n$filePath :"
$unchangedLines.Value += $fileContent | Where-Object { $_ -match 'OpenATV_7\.4_E2|"openATV 7\.4 enigma2"|OpenATV_7\.4_enigma2' }
}
} else {
Write-Host "File not found: $filePath"
}
}
$countChanged = [ref]0
$unchangedLines = [ref]""
$imageFiles = Get-ChildItem -Path "W:\oe-allianz\oe-alliance.core\bootmenu" -Recurse -Filter '*image*' -File
foreach ($file in $imageFiles) {
Manipulate-TextFile -filePath $file.FullName -countChanged $countChanged -unchangedLines $unchangedLines
}
Write-Host "Total number of modified 'openATV 7.4' lines: $($countChanged.Value)"
Write-Host "Lines not modified:"
Write-Host $unchangedLines.Value