I have a file toCreateFolders.dat:
D:\main\A\1
D:\main\B\2
D:\main\B\3
D:\main\C\4
D:\main\C\5
D:\main\D\6
I wanted to create the above directories using batch script:
@ECHO ON
for /f "tokens=* delims=" %%a in (D:\toCreateFolders.dat) do (
set line=%%a
DO IF NOT EXIST !line! MD !line!
)
EXIT
It’s not working.
Any suggestions?
>Solution :
I would advise that you try it like this:
@For /F "UseBackQ EOL=? Delims=" %%G In ("D:\toCreateFolders.dat") Do @If Not Exist "%%~G\." MD "%%~G"
or even like this:
@For /F "UseBackQ EOL=? Delims=" %%G In ("D:\toCreateFolders.dat") Do @MD "%%~G" 2>NUL