Windows Command Line Create File
Knowing how to conduct rudimentary file management at the Command Prompt comes in useful when you’re starting to code. Any file you make from the Command Prompt persists in multiple areas of Windows—this means that generating an index or document at the prompt fixes things so that you can access, utilize, and control that catalog or record in the Windows platform.
There are two ways to create files from the command line. The first method uses the fsutil command, and the second method uses the echo command.
Create File with Echo Command
|echo some-text > filename.txt
Create File with Fsutil Command
|fsutil file createnew filename number_of_bytes
Step-by-Step Process to Create Files via Command Line
STEP 1: Launch the command prompt.
The quickest way to implement this is to open the search bar by pressing Win + S, type cmd, and then select Command Prompt.
STEP 2: Choose the folder where you wish to save the file.
By default, the prompt will open under C:UsersYourName. Suppose the folder is elsewhere; type the cd path to the folder and hit Enter. Modify the way to the folder with the actual folder path.
STEP 3: Make a blank file.
Type |type nul > filename.txt
Modify filename.txt with a name according to your preference and hit Enter.
The “.txt” extension means that it’s a plain text file.
“.docx” (Word document), “.png” (empty photo), and “.rtf” (rich text document) are other popular file extensions.
All of these file formats may be viewed on any Windows system without the need for extra software.
Step 4: Make a file with certain text in it.
Replace testfile with the appropriate file name in copy con testfile.txt. Hit Enter.
Enter any text. This is a basic text editor, but it’s adequate for brief notes or coding. To move to the following line, use the Enter key.
Press Control + Z after you’re done editing the file.
Hit the Enter key. You should notice “1 file(s) copied,” meaning your file has been saved using the name you chose.
|echo enter your text here > filename.txt.
STEP 5: Make a file of a specific size.
Avoid this step, if you don’t wish to deliver a document of a specific size. Utilize the accompanying order to produce a clear text document dependent on its byte size.
|fsutil file createnew filename.txt 1000
Replace filename with the name of your wish and 1000 with the exact number of bytes you want the document to be.
Other useful articles:
- Basic Windows CMD commands
- Cool CMD Commands Tips and Tricks
- Best CMD Commands for Hacking
- CMD Commands for Wireless Network Speed
- Useful Keyboard Shortcuts for CMD
- What Info about My Laptop Can I Check with CMD and How?
- Getting Started with CMD Windows
- TOP-12 Command-Line Interview Questions (Basic)
- Command-Line Interview Questions (Advanced)
- CMD Commands to Repair Windows
- CMD Commands to Speed Up Computer
- CMD Commands for MAC OS
- How Does the Command Line Work?
- MS-Dos Interview Questions in 2021
- Windows OS Versions and History
- Recent Windows Versions Compared
- Basic Windows Prompt Commands for Every Day
- Windows Command Line Cheat Sheet For Everyone
- Windows Command Line Restart
- Windows Command Line for Loop
- Windows Command - Change Directory
- Windows Command - Delete Directory
- Windows Command Line – Set Environment Variable
- How Do I Run Command Line
- Windows Command Line Create File