diff --git a/replace.bat b/replace.bat
index 8f95f44..ac6e9df 100644
--- a/replace.bat
+++ b/replace.bat
@@ -1,42 +1,41 @@
@echo off
-chcp 65001 >nul
-setlocal enabledelayedexpansion
+setlocal
-if "%~1"=="" (
- echo ERROR: Specify file path
- echo Example: replace.bat "C:\path\to\file.xml" "https://gfx.tvstart.ru"
- exit /b 1
-)
-if "%~2"=="" (
- echo ERROR: Specify new URL
- echo Example: replace.bat "C:\path\to\file.xml" "https://gfx.tvstart.ru"
- exit /b 1
+set "vmix_file=%~1"
+if "%vmix_file%"=="" (
+ echo Usage: %0 filename.vmix
+ pause
+ exit /b 1
)
-set "FILE=%~1"
-set "NEWURL=%~2"
-
-if not exist "!FILE!" (
- echo ERROR: File not found: !FILE!
- exit /b 1
+if not exist "%vmix_file%" (
+ echo File "%vmix_file%" not found!
+ pause
+ exit /b 1
)
-echo Processing: !FILE!
-echo New URL: !NEWURL!
-echo.
+set "replace=https://per.tvstart.ru"
+set "temp_file=%vmix_file%.tmp"
-copy "!FILE!" "!FILE!.backup" >nul 2>&1
-if !errorlevel! equ 0 (
- echo Backup created: !FILE!.backup
+echo Processing: %vmix_file%
+
+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 (
- echo WARNING: Backup failed
+ echo Error: Failed to process file
)
-powershell -Command "$content = [System.IO.File]::ReadAllText('%FILE%'); $pattern = 'http[s]?://[^/<\"]+(/[^<\"]*)?'; $content = $content -replace $pattern, '%NEWURL%$1'; [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
\ No newline at end of file