How to Create and Delete Files or Folders from Windows Command Prompt
Create folder
Open Command Prompt in two quick ways:
Right-click the Start menu and select Command Prompt .
Press ⊞ Win+ Sto open the search bar, type cmd, then click Command Prompt in the search results.
Access the required folder. The Command Prompt window will display the command C:Users Your name by default. If you don't want to create a new folder here, type and press . Replace path_to_folder with the folder's path.cd path_to_folder ↵ Enter
For example, if you want to create a folder on the Desktop, you would type cd desktopand press ↵ Enter.
If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the path as well (for example: C:UsersTênDesktopFiles).
Enter Command Prompt.mkdir NamOfFolder Replace NameOfFolder with the name of the folder you want to create.
For example, to create a folder named "Homework", you would enter mkdir Homework.
Press ↵ Enter. This tells Command Prompt to create a folder with the name you want.
Delete folder
Open Command Prompt in two quick ways:
Right-click the Start menu and select Command Prompt .
Press ⊞ Win+ Sto open the search bar, type cmdand click Command Prompt in the search results.
Access the folder containing the folder you want to delete. The Command Prompt window will display the command C:Users Your name by default. If you want to delete another folder, you will enter and press . Replace path_to_folder with the folder's path.cd path_to_folder ↵ Enter
For example, if you want to delete a folder from the Desktop, enter cd desktop.
If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the entire path (e.g. C:UsersTênDesktopFiles).
Import .rmdir /s FolderName Replace FolderName with the name of the folder you want to delete.
For example, if you want to delete the "Homework" folder, you would enter it rmdir /s Homeworkhere.
If the folder name contains spaces (such as "Homework assignments"), you would enclose the name in quotation marks (for example: rmdir /s "Homework assignments").
Press ↵ Enterto execute the command.
If you want to delete a folder that contains hidden files or folders, you will see the error message "The directory is not empty". In this case, you will have to delete the "hidden" and "system" attributes of the files inside the folder. Do the following:
Used cdto change the folder you want to delete.
Execute the command dir /ato view a list of all files in the directory and their properties.
If you still cannot delete all the files in the directory, execute the command attrib -hs *. This removes special access permissions from files that cannot be deleted.
Enter cd .and press ↵ Enterto return to the previous folder.
Execute the command rmdir /sagain to delete the folder.
Press yto confirm. This will delete the folder permanently.
Create file
Open Command Prompt in two quick ways:
Right-click the Start menu and select Command Prompt .
Press ⊞ Win+ Sto open the search bar, type cmdthen click Command Prompt in the search results.
Go to the folder where you want to create the file. The Command Prompt window will display the command C:Users Your name by default. If you want to use another folder, you will enter and press . Replace path_to_folder with the folder's path.cd path_to_folder ↵ Enter
For example, if you want to create a file on the Desktop, enter cd desktopand press ↵ Enter.
If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the entire path (e.g. C:UsersTênDesktopFiles).
Create empty files in any format. If you don't want to create an empty file, go to the next step. The empty file will be created in the following way:
Type type nul > filename.txt .
Replace filename.txt with the file name and extension you like. Other common extensions include ".docx" (Word document), ".png" (empty image file), ".xlsx" (Excel document), and ".rtf" (for text has basic format).
Press ↵ Enter.
Create text files. If you don't want to create a text file, go to the next step. Use the following steps to create a raw text file into which you can import content:
Type , but replace testfile with the filename you prefer.copy con testfile.txt
Press ↵ Enter.
Enter content as you like. This is a rudimentary text editor, but still effective for writing code or taking quick notes. You can use the key Enterwhile editing to enter text on the next line if you like.
Press Ctrl+ Zwhen you finish editing the file. This operation saves all imported content to the file.
Another way to do this enter the .echo nhập nội dung tại đây > tên tập tin.txt
Create a file of a certain size. If you don't want to resize the file, skip this step. To create an empty file by byte size, you would execute the following command:
fsutil file createnew filename.txt 1000.
Replace filename with the name you want, and replace 1000 with the number of bytes needed for the file.
Delete files
Open Command Prompt in two quick ways:
Right-click the Start menu and select Command Prompt .
Press ⊞ Win+ Sto open the search bar, type cmdthen click Command Prompt in the search results.
Access the folder containing the file you want to delete. The Command Prompt window will display the command C:Users Your name by default. If you want to use another folder, you will enter and press . Replace path_to_folder with the folder's path.cd path_to_folder ↵ Enter
For example, if you want to create a file on the Desktop, enter cd desktopand press ↵ Enter.
If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the entire path (e.g. C:UsersTênDesktopFiles).
Enter dirand press ↵ Enterto open a list of all files in the current folder. You will see the file you want to delete in this list.
Files deleted using Command Prompt will be permanently deleted instead of being moved to the Recycle Bin. Therefore, you should be very careful when deleting files using Command Prompt.
Enter and press .del filename↵ Enter Replace filename with the full name and extension of the file you want to delete. The file name includes the file extension (such as *.txt, *.jpg). This will delete the file from your computer.
For example, to delete a text file named "hello", you would enter del hello.txtCommand Prompt.
If the filename contains spaces (e.g., "hi there"), you would enclose the filename in quotes (e.g., del "hi there").
If you receive a message that the file cannot be deleted, use the command , as this command is used to delete read-only files.del /f filename instead
You should read it
- How to Create and Delete Files and Directories from Windows Command Prompt
- Use CMD to delete large folders on Windows
- How to change the folder in Command Prompt on Windows 10
- How to Add and Delete User Accounts with Command Prompt on Windows
- How to find and open files with Command Prompt
- How to use the command history function in Command Prompt
- How to Open Folders in CMD
- How to Copy Files in Command Prompt
- 10 useful commands in Windows you should know
- How to Execute a Program in Command Prompt
- How to Change Directory in Command Prompt
- How to HIDE / SHOW files and folders by cmd command on Win 10/8/7
Maybe you are interested
Latest Sword Master Story Code and How to Enter Code
Latest Anime Squad Simulator Codes and How to Enter Codes
How to Center Taskbar Icons in Windows 10
Latest LaLa Land Code Mysterious Continent and how to enter code
Latest Holy Sword Reincarnation Code and how to enter
How to use Presenter View in Google Slides