When I enabled DelayedExpansion in the script, it doesn't echo out the "!" string in the file name. For instance:
Original
File01-TEXT!.txtEcho out
File01-TEXT.txt
I guess it's because of the setlocal EnableDelayedExpansion
, but I can't remove because I need it.
@echo off
setlocal EnableDelayedExpansion
cd "C:\Files"
for %%a in (*.txt) do (
REM Here's the problem...
echo %%a
set "str=%%a"
set new_str=!str:0,3!
)
echo %new_string%
pause >nul