MD: Creates a directory.


 


... The examples for the command "MD"
... "MD" Excerpt from Microsoft Windows Help
... Important information, tips for the "MD" command

The command: "MD" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available

The examples for the command "MD"

The `MD` command (also known as `MKDIR`) is used in the Windows Command Prompt to create a new directory (folder). Here are some examples: Example 1: Create a single directory:

@ECHO OFF
MD NewFolder

Description: This command creates a directory named "NewFolder" in the current working directory. Example 2: Create multiple nested directories:

@ECHO OFF
MD FirstDirectory\SecondDirectory\Subdirectory

Description: Three nested directories are created here: "FirstDirectory", "SecondDirectory" and "SubDirectory". The command automatically creates the required parent directories. Example 3: Create directory with absolute path:

@ECHO OFF
MD C:\MyDirectory

Description: A directory with the absolute path "C:\MyDirectory" is created here. Example 4: Creating directories and changing to the newly created directory at the same time:

@ECHO OFF
MD NewDirectory && CD NewDirectory

Description: The command creates a directory named "NewDirectory" and then changes to that directory. Example 5: Check if the directory already exists before creating it:

@ECHO OFF
IF NOT EXIST MyDirectory MD MyDirectory

Description: This checks whether the “MyDirectory” directory already exists. If not, it will be created using the `MD` command. Example 6: Create directories and ignore errors if they already exist:

@ECHO OFF
MD MyDirectory 2>NUL

Description: The command creates the directory "MyDirectory" and ignores error messages (if the directory already exists) with `2>NUL`. The `MD` or `MKDIR` commands are useful for creating directories in batch scripts. Note that you must have appropriate permissions to create directories in the specified path.

"MD" Excerpt from Microsoft Windows Help

Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.

C:\\WINDOWS>

Creates a directory.

MKDIR [drive:]path
MD [drive:]path

If Command Extensions are enabled MKDIR changes as follows:

MKDIR creates any intermediate directories in the path, if needed.
For example, assume \a does not exist then:

    mkdir \a\b\c\d

is the same as:

    mkdir \a
    chdir \a
    mkdir b
    chdir b
    mkdir c
    chdir c
    mkdir d

which is what you would have to type if extensions were disabled.

Important information, tips for the "MD" command

When using the `MD` command (or `MKDIR`) in the Windows Command Prompt, there are a few important points to note: 1. Permissions: To create a directory using the `MD` command, you need appropriate permissions for the specified location. Make sure you have sufficient permissions to create directories. 2. Path specification: The path you specify in the `MD` command can be absolute or relative. A relative path refers to the current working directory. An absolute path specifies the complete path, e.g. E.g. `C:\Example\Directory`. 3. Existing Directories: If you try to create a directory with `MD` and the directory already exists, you may receive an error. You can avoid this with the `IF NOT EXIST` check to check if the directory already exists before creating it.

    IF NOT EXIST MyDirectory MD MyDirectory
    
4. Nested Directories: The `MD` command automatically creates parent directories if they do not exist. So you can create nested directories by specifying the full path.

    MD First\Second\Subdirectory
    
5. Error Handling: If you want the script to continue even if a directory already exists, you can redirect the error output stream.

    MD MyDirectory 2>NUL
    
Here, the error output (error level 2) that might occur if the directory already exists is redirected to the null devices (NUL) and you don't get a visible error message. 6. Current Working Directory: The `MD` command creates the directory in the current working directory. You can use the `CD` command to change the current working directory before creating a directory if you want it to be created in a different location.

    CD C:\Example
    MD NewDirectory
    
It is important to ensure that the syntax of the `MD` command is correct and that you have the necessary permissions to create directories. Also note that error handling and checking for existing directories are often useful in batch scripts to avoid unexpected problems.


Deutsch
English
Español
Français
Italiano
日本語 (Nihongo)
한국어 (Hangugeo)
汉语 (Hànyǔ)
Türkçe
Português
Português
Svenska
Norsk
Dansk
Suomi
Nederlands
Polski









Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



The command MD - Creates a directory.

HTTP: ... console6.000000ko0.000000index.htm/en/040.htm
0.093
10560
Rotate the image or scan before create a PDF!
Gibt es einen 3D Text unter Windows 10/11 als Bildschirmschoner?
Unterschied Skript und Programm?
Is my Windows 10 / 11 up to date, can I see?
To-Tray / Infobereich Symbole der Windows Taskleiste anpassen, oder deaktivieren!
Disk Error Checking on Windows 10/11!
Quickly Change Current Time on you Windows 10/11!
Well suited as a cheap PowerPoint pointer?
Use the Photos app on Windows 10 / 11 to print pictures!
Difference between Notepad and WordPad Windows 11, 10, 8.1 + Server!



(0)