Windows batch remove squared brackets

@echo off
setlocal enableextensions disabledelayedexpansion

set "search1=["
set "replace1=("
set "search2=]"
set "replace2=)"

set "textFile=test.txt"

(for /f "delims=" %%i in ('type "%textFile%"') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search1%=%replace1%!"
set "line=!line:%search2%=%replace2%!"
echo(!line!
endlocal
)) > "%textFile%.tmp"

move /y "%textFile%.tmp" "%textFile%" >nul