Depending on the actual code, you can disable the pending extension, enable it when access to the modified content is required, and then disable it again
@echo off
setlocal enableextensions disabledelayedexpansion
cd "C:\Files"
for %%a in (*.txt) do (
set "str=%%a"
rem Option 1
echo file: %%a
setlocal enabledelayedexpansion
echo substring: !str:~0,3!
endlocal
rem Option 2 - capture changed value to use inside non delayed expansion context
setlocal enabledelayedexpansion
for %%b in ("!str:~0,3!") do (
enlocal
echo %%a -- %%~b
)
)
MC ND source
share