If you prefer using the command line or want to automate tasks, knowing how to create folders and files using Command Prompt (CMD) can save time and streamline your workflow. Windows 11 supports a wide range of commands that let you create directories, text files, batch files, and more—all without touching File Explorer.
In this guide, we’ll show you how to create folders and files from Command Prompt on Windows 11, including advanced options like creating multiple folders at once or generating files with content inside them.
1. Open Command Prompt on Windows 11
Before creating anything, open CMD in the right location.
- Press Windows + S and type cmd.
- Click Command Prompt.
- To open it with admin rights, choose Run as administrator.
- Use the following command to move to a directory:
cd path\to\folderExample:cd C:\Users\YourName\Documents
Now you’re ready to create folders and files.
2. How to Create a Folder Using Command Prompt
CMD uses the mkdir or md command to create directories.
Create a single folder
mkdir FolderName
Example
mkdir Projects
Create a folder with spaces in its name
Use quotes if the name contains spaces:
mkdir "Work Documents"
Create multiple folders at once
mkdir Folder1 Folder2 Folder3
Create nested folders in one command
mkdir ParentFolder\ChildFolder
CMD will create both automatically if the parent folder doesn’t exist.
3. How to Create an Empty File Using Command Prompt
Windows provides several ways to create a blank file from CMD.
Method 1: Use the type command
type nul > filename.txt
This creates an empty text file.
Method 2: Use echo command
echo. > filename.txt
Example
echo. > notes.txt
Method 3: Use copy command
copy nul filename.txt
All these methods create an empty file instantly.
4. How to Create a File With Content in CMD
You can generate a file and insert text into it at the same time.
Add a single line of text
echo This is my file content > file.txt
This overwrites the file if it exists.
Append text instead of overwriting
echo Additional text >> file.txt
Create multiple lines of text
Use this structure:
(
echo Line 1
echo Line 2
echo Line 3
) > file.txt
5. How to Create a Batch File in Command Prompt
Batch files use the .bat extension and can automate tasks.
- Open CMD.
- Use this command:
echo echo Hello World > script.bat - Run it by typing:
script.bat
Your batch file is now ready.
6. How to Create a Folder and File at the Same Time
You can combine commands using &&.
Example:
mkdir MyProject && echo. > MyProject\readme.txt
This command:
- Creates the MyProject folder
- Adds a readme.txt file inside it
7. Use Command Prompt to Create Files in a Different Directory
If you want to create a file without navigating into the folder:
Example
echo. > "C:\Users\YourName\Desktop\notes.txt"
Create a folder in another location
mkdir "D:\Backup\2024"
CMD handles full directory paths easily.
8. Create Multiple Files at Once Using a Loop
CMD loops can generate several files quickly.
Example: create 5 text files
for /l %i in (1,1,5) do echo. > File%i.txt
Result:
- File1.txt
- File2.txt
- File3.txt
- File4.txt
- File5.txt
This is useful for testing, automation, or scripting.
9. Create a Hidden or Read-Only File Using Attributes
After creating a file, you can modify its attributes.
Make a file read-only
attrib +r file.txt
Make a file hidden
attrib +h file.txt
Remove attributes
attrib -h -r file.txt
This gives you more control over file access.
Wrapping Up
Creating folders and files from the Windows Command Prompt is fast, flexible, and ideal for automation or advanced file management. Whether you’re generating empty files, creating directories, building batch scripts, or organizing nested folders, CMD offers simple commands that make the process efficient and powerful.
Once you get comfortable with these commands, you’ll be able to manage your Windows 11 file system far more quickly than using File Explorer alone.