Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Practice Problems
  • Python
  • C
  • C++
  • Java
  • Courses
  • Machine Learning
  • DevOps
  • Web Development
  • System Design
  • Aptitude
  • Projects
Open In App
Next Article:
How to Delete a File or Folder Using CMD?
Next article icon

How to Create a File in CMD

Last Updated : 07 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

We all know that one can easily create files using GUI options, but what if you can use a faster way to create files through the command-line interface? This is not a necessary but useful skill for anyone working with Windows. Whether you're automating tasks, working on scripts, or preferring using the command prompt, knowing how to create a file in CMD can be incredibly useful.

This article will walk you through the steps to create a file using CMD, ensuring that you can efficiently manage your files directly from the command prompt.

How-to-Create-a-File-in-CMD

Methods to Create A File on Windows using CMD

To start a new file on Windows using CMD, the following guidelines should be used. Let us start with the basic Echo Command.

Note: All of these methods should be executed in any certain directory. Otherwise, the operations will not completed. Use the CD Windows Command to enter into any certain Windows directory.

Method 1: Create Text File Using ECHO in Command Prompt

Step 1: Open CMD

  • To create a file using CMD open CMD press Win + R key on your keyboard and type CMD to open CMD.

Step 2: Type ECHO Command

  • Once the CMD opens execute the following command.

This method will directly save the file to the directory mentioned earlier. You have to put some text for it.

Command: echo.  > Rapture.txt
echo-cmd
Echo command

Congratulation! The New Text File on Windows is created using the Command Prompt with one simple command.

Method 2: COPY CON Command to Create a New File

Step 1: Use copy con in CMD

  • You need to type "copy con" followed by the name of the file you wish to overwrite and once you're done press the CTRL + Z to end the operation & the file will be directly saved to the directory.

Let's understand this with the below-mentioned example where the file name = 'Rapture'

Command: copy con Rapture.txt
cmd-copy-con
copy con command

Hooray! We have successfully created a Text File on Command Prompt on Windows in a certain directory without opening it.

Method 3: Quick Guide to Create a File in CMD - NOTEPAD Command

The following command can be used to open any Text File. Either, you can open the New File with any predefined name or any existing one in the certain directory. It will open the Notepad Windows Application, make changes there & press CTRL + S to save it.

Command: notepad Rapture.txt
cmd-notepad-file-creation
notepad command

Method 4: 'fsutil' Command to create a "specific" size file

The following command can be used to create a file in CMD for any specific size. Once you create the file, you do perform tasks accordingly.

For example: Let's create a file of size 10 bytes with the filename as 'Rapture'

Command: fsutil file createnew Rapture.txt 10
cmd-fsutil
'fsutil' Command

Method 5: "type nul" Command to create a new File

The type nul command in cmd can be used to create a new file wherein the "type nul" denotes to do nothing and starts with an empty file. Let's understand this with an example below where the filename is 'Rapture'.

Command: type nul >Rapture.txt
type-null
type null command

Conclusion

Mastering the ability to create a file in CMD is an essential part of becoming proficient with the command line in Windows. By using the right CMD command to create a file, you can streamline your workflow and perform tasks more efficiently. Whether you’re creating simple text files or working on more complex scripts, understanding how to make a file in CMD gives you greater control over your system.

Also Read

  • Most Useful CMD Commands in Windows
  • CMD Commands to Gather Information of a System
  • How to Show all the previously connected WiFi Networks using CMD in Windows?

Next Article
How to Delete a File or Folder Using CMD?
author
sounetraghosal2000
Improve
Article Tags :
  • TechTips
  • How To
  • Command Prompt

Similar Reads

  • How to Create a Batch File in Windows?
    A batch file is a straightforward text document in any version of Windows with a set of instructions meant to be run by Windows' command-line interpreter (CMD) by maintaining all the functions. Batch files are a great tool for streamlining internally configured processes, automating tedious jobs, an
    5 min read
  • How to Create an Empty File in Linux | Touch Command
    The touch command is a standard command used in the UNIX/Linux operating system which is used to create, change and modify the timestamps of a file. Basically, there are two different commands to create a file in the Linux system which are as follows: touch command: It is used to create a file witho
    8 min read
  • How to Create an Unnamed file in Windows?
    There is curiosity hidden inside everyone. So when it comes to computers we all try to know why this is happening, what will happen if I run this software, what will happen if I delete some of Windows files and etc. We also sometimes try to make a file without a name in Windows and fail and then, fi
    2 min read
  • How to Delete a File or Folder Using CMD?
    While working on Windows devices, we used to work on Windows File Explorer for working with files. On File Explorer of Windows, the creation of new files as well as deleting old ones is one of the easiest processes. However, if your File Explorer is not responding, then the process to Delete Folder
    5 min read
  • Create a Temporary File in Java
    In Java, we can create a temporary file using an existing method known as File.createTempFile() method which creates a new empty file on the specified directory. The createTempFile() function creates a temporary file in a given directory (if the directory is not mentioned then a default directory is
    4 min read
  • How to List all Files in a Directory using CMD
    Struggling to find or organize files buried in folders on your Windows PC? While File Explorer offers a visual way to browse, the Command Prompt (CMD) provides a faster, more powerful method to list, sort, and manage files, especially when dealing with large directories or automating tasks. In this
    5 min read
  • How to create and write to a txt file using VBA
    This VBA Program reads an Excel Range (Sales Data) and writes to a Text file (Sales.txt). This helps in faster copying of data to a text file as VBA coding enables automated copying. Let us learn how to do it in a few easy steps: Excel VBA Write Text FileIn the realm of Excel VBA, the power to inter
    5 min read
  • How to Append Data to a File in MATLAB?
    Appending data to a text file means adding data to a file that already exists in the storage. print() function is used to write/append data to a file in MATLAB. It writes formatted text to a file based on the format string provided to it. The format of the output/input is determined by the formattin
    4 min read
  • How to Create a Text File Using the Command Line in Linux
    The Linux command line is a powerful tool that allows you to manage your system with precision and speed. One of the most common tasks is creating a text file, which can be achieved using several commands and methods. Here we will learn some quick ways to create a text file from the Linux Command Li
    6 min read
  • How to Create a File in VSCode using Terminal?
    In a few cases touch or new-item or any other base keywords may not be used to create a file in vs code due to the absence of extensions, but using the following approach you can create and code any type of file with ease. In this article, you will learn about how to create a file with any file type
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences