0

For a project I received 700 folders with names of institutions (containing spaces). The purpose is now to create subfolders in each of these folders.

[institution folder]\Documents\ [institution folder]\Images\ [institution folder]\Videos\

According some posts here the below script should work to create the Documents folder

FOR /d %A IN (C:\Users\myname\project\institutions\*) DO mkdir %A\Documents 

However, I notice in the feedback that I get from the command line that this instruction fails at the spaces in the foldername. How can I get this to work?

2 Answers 2

3
FOR /d %A IN (C:\Users\myname\project\institutions\*) DO mkdir "%A"\Documents 

should do the trick.

Sign up to request clarification or add additional context in comments.

Comments

2

make sure you wrap expressions containing spaces with " to make sure the shell sees them as a single entity.

6 Comments

Yes I know, but the problem is, how do I handle that with my %A variable?
CLI feedback: "%A" is not expected at this moment.
have you looked at that link i posted last? sounds like it has your solution in there
You place the quotes around the %A in the MKDIR, but not in the FOR thus: FOR /d %A IN (C:\Users\myname\project\institutions\*) DO mkdir "%A"\Documents
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.