I’m trying to get substrings of file names in a current folder. Later I’m going to pass these as arguments to a certain command but as for now I can’t even make echo to work:
setlocal EnableDelayedExpansion
for %%f in (*.mvx) do (
set a=%%f
echo %a%
echo %%a%%
echo %a:~3,8%
)
endlocal
pause
yields results of the kind:
C:\1>(
set a=xx-20121213-mvl-0005.mvx
echo
echo %a%
echo ~3,8
)
ECHO is on.
%a%
~3,8
the last one is supposed to return “20121213” for the case.
You need to use delayed expansion to echo your variables, as you have set them in a
forloop.You have already included the line to enable it, you just need to turn your
%‘s into!‘sUpdate
To put the entire script on a one line cmd command you can use