Command line: Create folders in subfolders with sp

2019-04-17 07:11发布

问题:

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?

回答1:

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

should do the trick.



回答2:

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