I have the following code in my batch, which I want to read the lines in test.txt, create a folder with the first 2 Characters and make config ini files for the respective items in their intented folder.
Here is the structure of my code:
@echo off
for /f "tokens=*" %%i in (test.txt) do (
set first2=%i:~0,2%
md "C:\Documents and Settings\someuser\Desktop\template\config\%first2%" 2>nul
type part1.txt>"C:\Documents and Settings\someuser\Desktop\template\config\%first2%\%%i"
echo.>>"C:\Documents and Settings\someuser\Desktop\template\config\%first2%\%%i"
echo Hostname=%%i.somedns.net>>"C:\Documents and Settings\someuser\Desktop\template\config\%first2%\%%i"
type part2.txt>>"C:\Documents and Settings\someuser\Desktop\template\config\%first2%\%%i"
)
Pause
Example of input from test.txt:
OR0001R1
OR0001R2
OR0008R1
OR0009R1
OR0009R2
OR0009R3
OG0001R1
OG0001R2
OG0002R1
OG0003R1
My problem is the following, instead of creating folder OR in which it then creates OR0001R1.ini and so on and afterwards create folder OG for the OG inis, it only creates folder OR and all the config inis in it. Can someone help me with this ?