My Windows batch file is supposed to read file names and create a directory that is named according to the filename's 2nd to 5th letter:
for %%f in (.\*.txt) do (
set string=%%~nf
mkdir %string:~2,5%
)
The value of 'string' is not updated though, i.e. it is the same in each step of the loop. How can I have it updated?
This is the cmd output:
>for %f in (.\*.txt) do (
set string=%~nf
mkdir le3
)
>(
set string=file1
mkdir le3
)
>(
set string=file2
mkdir le3
)
A subdirectory or file le3 already exists.
>(
set string=file3
mkdir le3
)
A subdirectory or file le3 already exists.