[CmdletBinding()]
param()
$ErrorActionPreference = ‘Stop’
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$root = Split-Path -Parent $PSCommandPath
function Get-Topic {
param([string]$BaseName)
$n = $BaseName.ToLower()
if ($n -match ‘zahlung|auszahlung|einzahlung|kasse|krypto|transaktion|limits’) { return ‘payments’ }
if ($n -match ‘bonus|promotion|freispiel|cashback|umsatz’) { return ‘bonus’ }
if ($n -match ‘spiel|slot|live|anbieter|provider|lobby|games|titel’) { return ‘games’ }
if ($n -match ‘sicherheit|support|datenschutz|faq|vertrauen|schutz|hilfe|service’) { return ‘trust’ }
if ($n -match ‘anmeldung|registrierung|login|konto|zugang|startseite|kontostart’) { return ‘registration’ }
return ‘platform’
}
function Pick {
param(
[object[]]$Items,
[int]$Index
)
return $Items[$Index % $Items.Count]
}
function New-ShortName {
param(
[string]$Topic,
[int]$Index
)
$subjects = @{
bonus = @(
‘Bonus’, ‘Bonusregeln’, ‘Freispiele’, ‘Startbonus’, ‘Bonusblick’, ‘Bonuswahl’,
‘Bonusplan’, ‘Bonusstart’, ‘Bonustipps’, ‘Promo Blick’, ‘Promo Start’, ‘Reload Bonus’,
‘Cashback’, ‘Freispin Plan’, ‘Bonus Guide’, ‘Bonuspfad’
)
payments = @(
‘Zahlungen’, ‘Auszahlung’, ‘Kasse’, ‘Zahlweg’, ‘Cashout’, ‘Krypto’,
‘Zahlplan’, ‘Kassenblick’, ‘Kassenhilfe’, ‘Transferweg’, ‘Zahlhilfe’, ‘Konto Cashout’,
‘Zahlfluss’, ‘Auszahlweg’, ‘Kassenstart’, ‘Zahlregeln’
)
games = @(
‘Slots’, ‘Live Casino’, ‘Spielwahl’, ‘Spiele’, ‘Casino Games’, ‘Spielblick’,
‘Slotwahl’, ‘Live Spiele’, ‘Lobby Guide’, ‘Titelblick’, ‘Game Fokus’, ‘Spielewelt’,
‘Live Tische’, ‘Slot Guide’, ‘Lobby Plan’, ‘Spielmix’
)
trust = @(
‘Sicherheit’, ‘Support’, ‘Datenschutz’, ‘Vertrauen’, ‘Hilfeblick’, ‘Serviceplan’,
‘Sicher Start’, ‘Kontoschutz’, ‘Schutzblick’, ‘Service Guide’, ‘Trust Fokus’, ‘Hilfeplan’,
‘Supportblick’, ‘Sicher Guide’, ‘Serviceblick’, ‘Trust Plan’
)
registration = @(
‘Anmeldung’, ‘Registrierung’, ‘Login’, ‘Kontostart’, ‘Zugang’, ‘Startseite’,
‘Kontoblick’, ‘Startblick’, ‘Anmeldeplan’, ‘Loginhilfe’, ‘Start Guide’, ‘Kontozugang’,
‘Anmeldestart’, ‘Reg Blick’, ‘Startpfad’, ‘Loginplan’
)
platform = @(
‘Plattform’, ‘Casino Blick’, ‘Startblick’, ‘Seitenplan’, ‘Nutzerblick’, ‘Portalplan’,
‘Casino Start’, ‘Seitenhilfe’, ‘Plattformplan’, ‘Portalblick’, ‘Casino Guide’, ‘Nutzerplan’,
‘Start Guide’, ‘Seitenblick’, ‘Portalstart’, ‘Casino Fokus’
)
}
$middles = @(
‘Klarer Start’, ‘Direkter Zugang’, ‘Schnelle Sicht’, ‘Klare Wege’,
‘Praktische Hilfe’, ‘Moderner Blick’, ‘Kompakte Form’, ‘Aktive Nutzung’,
‘Saubere Struktur’, ‘Starke Ordnung’, ‘Mobile Sicht’, ‘Runder Ablauf’,
‘Klare Linie’, ‘Schnelle Wege’, ‘Direkte Hilfe’, ‘Freier Wechsel’,
‘Kluger Fokus’, ‘Stabile Form’, ‘Kurzer Weg’, ‘Klarer Plan’,
‘Gute Uebersicht’, ‘Direkter Blick’, ‘Klare Menues’, ‘Schneller Start’
)
$endings = @(
‘Im Fokus’, ‘Im Ueberblick’, ‘Mit Struktur’, ‘Mit Klarheit’,
‘Mit Ordnung’, ‘Kompakt Gesehen’, ‘Mit Praxis’, ‘Im Direktblick’,
‘Mit Uebersicht’, ‘Mit Vorteil’, ‘Mit Orientierung’, ‘Im Alltag’,
‘Mit Weitblick’, ‘Mit Profil’, ‘Mit Plan’, ‘Mit Zugang’,
‘Mit Vertrauen’, ‘Mit Tempo’, ‘Mit Spielsicht’, ‘Mit Bonussicht’,
‘Mit Klarblick’, ‘Mit Nutzwert’, ‘Mit Logik’, ‘Mit Leitbild’,
‘Mit Profilblick’, ‘Mit Startwert’, ‘Mit System’, ‘Mit Spielplan’,
‘Mit Echtgeldblick’, ‘Mit Kontoblick’, ‘Mit Seitenblick’, ‘Mit Mehrwert’
)
$subjectList = $subjects[$Topic]
$subjectCount = $subjectList.Count
$middleCount = $middles.Count
$endingCount = $endings.Count
$n = $Index
$s = $n % $subjectCount
$m = [math]::Floor($n / $subjectCount) % $middleCount
$e = [math]::Floor($n / ($subjectCount * $middleCount)) % $endingCount
$base = ‘Happy Hugo ‘ + $subjectList[$s] + ‘ ‘ + $middles[$m] + ‘ ‘ + $endings[$e]
$base = [regex]::Replace($base, ‘\s+’, ‘ ‘).Trim()
if ($base.Length -gt 61) {
$base = $base.Replace(‘Kompakt Gesehen’, ‘Kompakt’)
$base = $base.Replace(‘Gute Uebersicht’, ‘Uebersicht’)
$base = $base.Replace(‘Direkter Zugang’, ‘Direkt’)
$base = $base.Replace(‘Praktische Hilfe’, ‘Praxis’)
$base = [regex]::Replace($base, ‘\s+’, ‘ ‘).Trim()
}
if ($base.Length -gt 61) {
throw “Name too long: $base”
}
return $base
}
$files = Get-ChildItem -Path $root -File -Filter ‘*.txt’ | Sort-Object Name
$topicCounters = @{
bonus = 0
payments = 0
games = 0
trust = 0
registration = 0
platform = 0
}
$used = New-Object ‘System.Collections.Generic.HashSet[string]’
$plan = @()
$tempIndex = 0
foreach ($file in $files) {
$topic = Get-Topic -BaseName $file.BaseName
$localIndex = $topicCounters[$topic]
do {
$candidate = New-ShortName -Topic $topic -Index $localIndex
$localIndex++
} until ($used.Add($candidate))
$topicCounters[$topic] = $localIndex
$plan += [pscustomobject]@{
OldPath = $file.FullName
TempName = ‘__tmprename_’ + $tempIndex.ToString(‘D5’) + ‘.txt’
FinalName = $candidate + ‘.txt’
}
$tempIndex++
}
foreach ($item in $plan) {
Rename-Item -Path $item.OldPath -NewName $item.TempName
}
foreach ($item in $plan) {
Rename-Item -Path (Join-Path $root $item.TempName) -NewName $item.FinalName
}
Write-Output (‘RENAMED=’ + $plan.Count)



Deja un comentario