Загрузка данных


$inputFolder = "C:\ИГРА\ПАПКА_С_TXT"
$outputFolder = "C:\ИГРА\ПАПКА_С_JSON"

if (!(Test-Path $outputFolder)) { New-Item -ItemType Directory -Path $outputFolder }
$files = Get-ChildItem -Path $inputFolder -Filter *.txt

foreach ($file in $files) {
    $lines = Get-Content -Path $file.FullName -Encoding UTF8
    $fileData = @{}
    $index = 1
    foreach ($line in $lines) {
        if ($line -match 'MESSAGE\([^,]+,\s*"([^"]+)"') {
            $fileData["line_$index"] = $Matches[1]
            $index++
        }
    }
    if ($fileData.Count -gt 0) {
        $newFileName = $file.BaseName + ".json"
        $newFilePath = Join-Path $outputFolder $newFileName
        $fileData | ConvertTo-Json | Set-Content -Path $newFilePath -Encoding UTF8
    }
}
Write-Host "Готово! Новая папка с правильными JSON создана." -ForegroundColor Green