DOS create folder MD

Time:2021-3-1

If you want to create a folder with spaces or &, you need to use quotation marks to enclose the folder name, for example: MD “test ABC”, MD “ABC & XYZ”. What happens if you don’t use quotation marks?

The results are as follows

1. If the folder name has spaces, the MD test ABC statement will create two folders, test and ABC, in the current directory. By using this feature, we can sometimes get the wonderful effect of simplifying: if we want to create three folders, just use MD ABC def XYZ instead of three MD statements. Of course, MD ABC; def; XYZ or MD ABC, def, XYZ are also acceptable.
2. If there is & in the folder name, MD ABC & XYZ will create the ABC folder and prompt that ‘XYZ’ is not an internal or external command, nor a runnable program or batch file. This is because & is the connection symbol of a compound statement. It regards the front and back parts as two sub statements.

Caution: if folder names contain special symbols, don’t forget to use double quotes!

MD also has a more convenient function: to create intermediate directory. In other words, commands like MD A / B / C can create folder a under the current directory, then create folder B under a, and then create folder C under B, all at once. There is no need to first MD a, then CD a, then MD B, then CD B, then MD C.