ТЩЕ ЦЩКЛШТП!

This commit is contained in:
Alexey Barabanov
2025-11-10 13:14:22 +03:00
parent 225e26a1bb
commit cf06adbfab

View File

@@ -1,42 +1,41 @@
@echo off @echo off
chcp 65001 >nul setlocal
setlocal enabledelayedexpansion
if "%~1"=="" ( set "vmix_file=%~1"
echo ERROR: Specify file path if "%vmix_file%"=="" (
echo Example: replace.bat "C:\path\to\file.xml" "https://gfx.tvstart.ru" echo Usage: %0 filename.vmix
exit /b 1 pause
)
if "%~2"=="" (
echo ERROR: Specify new URL
echo Example: replace.bat "C:\path\to\file.xml" "https://gfx.tvstart.ru"
exit /b 1 exit /b 1
) )
set "FILE=%~1" if not exist "%vmix_file%" (
set "NEWURL=%~2" echo File "%vmix_file%" not found!
pause
if not exist "!FILE!" (
echo ERROR: File not found: !FILE!
exit /b 1 exit /b 1
) )
echo Processing: !FILE! set "replace=https://per.tvstart.ru"
echo New URL: !NEWURL! set "temp_file=%vmix_file%.tmp"
echo.
copy "!FILE!" "!FILE!.backup" >nul 2>&1 echo Processing: %vmix_file%
if !errorlevel! equ 0 (
echo Backup created: !FILE!.backup powershell -Command "
$content = Get-Content '%vmix_file%' -Raw
$pattern = 'https?:\/\/\d*\.\d*\.\d*\.\d*:\d*|https?:\/\/\w*\.\w*\.\w*'
$replacement = '%replace%'
$result = $content -replace $pattern, $replacement
$result | Out-File '%temp_file%' -Encoding UTF8
"
if exist "%temp_file%" (
move /y "%temp_file%" "%vmix_file%" > nul
echo Replacement completed successfully!
echo URLs matching these patterns were replaced:
echo - IP addresses with ports (http://127.0.0.1:8000 etc.)
echo - Three-part domains (https://gfx.tvstart.ru etc.)
echo Replacement: %replace%
) else ( ) else (
echo WARNING: Backup failed echo Error: Failed to process file
) )
powershell -Command "$content = [System.IO.File]::ReadAllText('%FILE%'); $pattern = '<url>http[s]?://[^/<\"]+(/[^<\"]*)?</url>'; $content = $content -replace $pattern, '<url>%NEWURL%$1</url>'; [System.IO.File]::WriteAllText('%FILE%', $content, [System.Text.Encoding]::UTF8); Write-Host 'SUCCESS: Replacement completed'"
if errorlevel 1 (
echo ERROR: PowerShell command failed
)
echo.
pause pause