You can use Windows Command Prompt (cmd.exe) to carry out many operations related to files and folders, for instance, you can create/delete a file or folder with CMD, open a file/folder with CMD, as well as hide/unhide a file with CMD. Check how to use CMD command lines to perform these actions below.
At first, you need to access Command Prompt application in Windows 10. You can press Windows + R to open Windows Run dialog, type cmd in it, and click OK or press Enter to open normal Command Prompt window. To create/delete/open/hide a file or folder using CMD, you don�t have to open elevated Command Prompt in Windows.
How to Create a File/Folder with CMD
Step 1. Go to the Right Folder Directory
After you enter into Command Prompt window, you can type cd folder path and press Enter to go to the directory in which you want to create a file or folder. You should replace �folder path� with the actual folder path, e.g. cd desktop.
Please be noted that, if the default directory, after you enter into cmd.exe, isn�t your desired directory where you want to create the file/folder, you should type the whole directory path after �cd� in the command line.
Step 2. Create a File/Folder with CMD
After you are in the right folder path, you can type mkdir folder name and hit Enter key to create a folder with CMD. Please replace the �folder name� with the actual preferred folder name, e.g. mkdir work.
If you want to create a file with Command Prompt, you can type the command lines below. Remember to press Enter button after you type each command line.
To create an empty file, you can type type nul > filename.fileextension, e.g. type nul > work.docx.
To create a file with certain texts in it, you can type echo enter your text here >filename.fileextension, e.g. echo How to Create a File with CMD >work.txt.
You should replace �filename.fileextension� with the actual name and extension of the file, and replace �enter your text here� with the actual texts you want to include into the file.
To create a file with a preferred file size, you can type fsutil file createnew filename.docx 5000 in Command Prompt. You can replace �5000� with the preferred file byte size and replace �filename� with the name of the file.
How to Delete a File/Folder with CMD
You can follow the Step 1 above to go to the right directory in Command Prompt.
Type rmdir /s folder name (e.g. rmdri /s work), and hit Enter. Continue to type �Y� to delete a folder with CMD.
To delete a file with command line, you can type del filename.fileextension (e.g. del work.txt), and press Enter to delete the file.
If the file or folder name has spaces, you should include the file/folder name into quotations.
Tip: To quickly find the file and its extension, you can type dir command in Command Prompt to list all the files and folders in the current directory.
Please be aware that using CMD to delete a file or folder will permanently delete it. So please be careful with the deletion. If you mistakenly deleted an important file or folder, you can use MiniTool Power Data Recovery, the professional data recovery software for Windows 10/8/7, to easily retrieve deleted or lost files for free.
How to Open a File/Folder Using CMD
If you want to open a file in Command Prompt, you have two ways to do it.
You can type cd folder path (e.g. cd C:\Users\mini\Desktop), and then type the filename.fileextension with quotations (e.g. �travel.png�), and press Enter to open the file with CMD.
Alternatively, you can also type the whole file path in Command Prompt with quotations (e.g. �C:\Users\mini\Desktop\travel.png�) to open the target file.
To open a folder in CMD, you can type start %windir%\explorer.exe �folder path� (e.g. start %windir%\explorer.exe �C:\Users\mini\Desktop�). The folder path should be in quotations.
How to Hide/Unhide a File/Folder with CMD
After you enter into Command Prompt window, you can type the attrib command to hide or unhide a file with CMD.
To hide a file, you can type attrib +h file path (e.g. attrib +h C:\Users\mini\Desktop/travel.png) and hit Enter to hide the file.
If you want to unhide the file later, you can type attrib -h file path (e.g. attrib -h C:\Users\mini\Desktop/travel.png) to unhide it.
Alternatively, you can also type cd folder path to go to the folder directory where the file or folder is stored, and type attrib +h filename.fileextension or attrib �h filename.fileextension to hide/unhide the file in Command Prompt.
Aside from creating, deleting, opening, or hiding file/folder with CMD, you can also use many other Windows command lines to do more things with ease.