How to use the command mkdir (with examples)
- Windows
- December 25, 2023
The mkdir
command in Windows is used to create a new directory. It allows users to effortlessly create new directories and organize files and folders in an efficient way.
Use case 1: Create a directory
Code:
mkdir path\to\directory
Motivation: This use case is useful when you need to create a single directory at a specific path. For example, if you want to create a new directory named “documents” under the path “C:\Users\Username”, you would use this command.
Explanation:
mkdir
: This is the command itself, which stands for “make directory.”path\to\directory
: This is the path where the new directory should be created. Replace this with the actual path you want to use.
Example output:
C:\Users\Username\documents
Use case 2: Create a nested directory tree recursively
Code:
mkdir path\to\sub_directory
Motivation: This use case is helpful when you want to create a nested directory structure, including multiple levels of subdirectories. The -p
option enables creating parent directories if they don’t already exist.
Explanation:
mkdir
: This is the command itself, which stands for “make directory.”path\to\sub_directory
: This is the path where the new nested directory should be created. Replace this with the actual path you want to use.
Example output:
C:\Users\Username\path\to\sub_directory
Conclusion:
The mkdir
command in Windows is a versatile tool for creating directories. With the ability to create both single directories and nested directory trees, it allows for efficient organization and management of files and folders. Whether you need to create a simple directory or a complex directory structure, mkdir
has you covered.