Code: Select all
@echo off
setlocal EnableDelayedExpansion
for /R H:\archive %%f in (*.*) do (
set "name=%%f"
if "!name:~100,1!" neq "" (
for /L %%i in (100,1,500) do if "!name:~%%i,1!" neq "" set /A len=%%i+1
echo !len!: !name!
)
)
It works. Unfortunately one of the parameters inside the for loop is a fix value (100).
Now I search for a way to´parameterize it. However the following does NOT work:
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set threshold=100
for /R H:\archive %%f in (*.*) do (
set "name=%%f"
if "!name:~!threshold!,1!" neq "" (
for /L %%i in (:~!threshold!,1,500) do if "!name:~%%i,1!" neq "" set /A len=%%i+1
echo !len!: !name!
)
)
I guess because DOS does not accept nested exclamation marks
How else should I rewrite the first code to get it working?
Thank you
Peter