1.

Solve : Help create folders from a txt file including subdirs?

Answer»

Hi. I found a simple BATCH program that will create directorie/folders from a txt file (ie., LIST.txt). It looks like this:
Code: [Select]@echo off
for /f %%i in (folders.txt) do mkdir %%i

However, it only works if your list in the txt file has single level directories, like this:
Code: [Select]folder1
folder2
folder3
etc...
What does the code need to add subfolders like this:

EXAMPLE txt file:
Code: [Select]folder1/subfolder1
folder2/subfolder2
folder3/subfolder3
etc...
?

The bat file will not make the subfolder. Is there a way to do it?In folders.txt change all the / to \

then it will work. I just tested it.

Thanks. That was a typo. My txt file has '\'. The problem is when you add a space in the name: 'folder 1\subfolder1'. The program will only create:'folder'. It's probably a simple solution of which i don't know Quote from: adabo on May 02, 2010, 08:10:20 AM

Thanks. That was a typo. My txt file has '\'. The problem is when you add a space in the name: 'folder 1\subfolder1'. The program will only create:'folder'. It's probably a simple solution of which i don't know

1. The default token delimiter in FOR /F is a space, so FOR will stop at the first space in each line of folders.txt. You must make FOR take the WHOLE line by USING "delims=".

2. In mkdir or any other operation where a file, folder or path name has one or more spaces, use quote marks. You can use them anyway, they do no harm.

mkdir "A folder name with spaces"

Code: [Select]@echo off
for /f "delims=" %%i in (folders.txt) do mkdir "%%i"


Discussion

No Comment Found