0

I would like to create a lot of folders at once. I have a text file that contains all the names I need. But I'm not able to use this file as an "input".

Here's my code:

for /F "tokens=*" %%A in (listfolder.txt) do (
    set name=%%A
    xcopy /i /e "C:\Users\Documents\00 template" "C:\Users\Documents\%name%"
)

I also tried

xcopy /i /e "C:\Users\Documents\00 template" "C:\Users\Documents\" AND %name%

and

xcopy /i /e "C:\Users\Documents\00 template" "C:\Users\Documents\" AND %%A

Can someone explain me what I'm doing wrong? Pretty new to batch - For example, "tokens=*" I don't get the reason behind this. I just find the information on internet.

Thanks all,

Iswaren
  • 3
  • 4
  • 1
    typical [delayed expansion issue](https://stackoverflow.com/questions/30282784/variables-are-not-behaving-as-expected/30284028#30284028), but you don't need the `name` variable. Just ` xcopy /i /e "C:\Users\Documents\00 template" "C:\Users\Documents\%%A"` – Stephan Mar 02 '20 at 16:59
  • 1
    `for /?` should answer your question about `tokens` and `delims`. – Stephan Mar 02 '20 at 17:01
  • Stephan : Thanks. It seems that it was the only option I did not test! I can confirm that it works actually. Mind to write an answer and I mark it as answer ? :) – Iswaren Mar 02 '20 at 17:14
  • 1
    There are literally hundreds of such questions. No need to add another identical answer. I marked your question as a duplicate of one of them. – Stephan Mar 02 '20 at 17:46

0 Answers0