I have a for loop reading lines from a file called "temp". It should read each line and then proceed to create a directory for each name in the file. However, it's reading the first line of the file twice before it moves to the second line. So I get an error saying the folder already exists.
The file "temp" contains, for now, two entries:
folder1
folder2
The code is simple:
for /F "tokens=*" %%i in (temp) do (
set pstname=%%i
echo the folder name is set to %pstname%
mkdir C:\output\%pstname%
)
When I run this, it reads the first line, folder1, from the "temp" file and creates the directory c:\output\folder1. So I expect that in the next iteration the variable pstname will be set to the second line in the "temp" file (should be set to folder2)
But that is not what happens. The loop reads fodler1 twice and attempts to create the folder1 folder again. If I continue with the script it eventually reads the second line from the "temp" file (folder2) and creates it. So the script almost works.
Issue: What am I doing wrong? It reads the first line in the file "temp" twice before it proceeds to the next line?
Is there a next command I have to use? What is wrong with my logic?