1

I'm new to writing batch files so I'm still a trying to work things out. Basically, I want to create a .bat file that will create a list of directories with a incremented number on the end. For my example I will get files with the names "Week1", "Week2", "Week3" ... "Week52". My code is as follows:

set "prefix=Week" for /l %%x in (1, 1, 52) do ( set /a num=%%x set direc=%prefix%%num% mkdir %direc% )

I think the trouble comes on the line where I concatenate the string and the numbers but I'm not 100% sure. Any pointers/corrections? Thanks in advance!

GBean
  • 41
  • 9

1 Answers1

1

you need delayed Expansion:

setlocal enabledelayedexpansion
set "prefix=Week"
for /l %%x in (1, 1, 52) do (
  set /a num=%%x
  set direc=%prefix%!num!
  mkdir !direc! 
) 

but why creating variables?

set "prefix=Week"
for /l %%x in (1, 1, 52) do mkdir %prefix%%%x
Community
  • 1
  • 1
Stephan
  • 53,940
  • 10
  • 58
  • 91