You are viewing the article How to Create and Delete Files or Folders from Windows Command Prompt at Lassho.edu.vn you can quickly access the necessary information in the table of contents of the article below.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 41,397 times.
This is an article that shows you how to use Command Prompt on Windows to create and delete files and folders (also known as directories). Files that you create from the Command Prompt can be edited and managed using Windows applications, including File Manager and text editors.
Steps
Create folder
- Right-click the Start menu and select Command Prompt .
- Press ⊞ Win + S to open the search bar, type cmd , and then click Command Prompt in the search results.
- For example, if you wanted to create a folder on the Desktop, you would type cd desktop and press ↵ Enter .
- If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the path (e.g. C:UsersNameDesktopFiles ).
- For example, to create a folder named “Homework”, you would type mkdir Homework .
Delete folder
- Right-click the Start menu and select Command Prompt .
- Press ⊞ Win + S to open the search bar, type cmd and click Command Prompt in the search results.
- For example, if you want to delete a folder from the Desktop, type 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:UsersNameDesktopFiles ).
- For example, if you wanted to delete the “Homework” directory, you would enter rmdir /s Homework here.
- If the folder name contains spaces (such as “Homework assignments”), enclose the name in quotes (e.g. rmdir /s "Homework assignments" ).
- 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 remove the “hidden” and “system” attributes of the files inside the directory. Do the following: [2] X Research Sources
- Use cd to change to the directory you want to delete.
- Execute the command dir /a to see a list of all files in the directory and their properties.
- If you still cannot delete all files in the directory, execute the command attrib -hs * . This is a special access removal operation from files that cannot be deleted.
- Type cd .. and press ↵ Enter to return to the previous directory.
- Execute the command rmdir /s again to delete the directory.
Create file
- Right-click the Start menu and select Command Prompt .
- Press ⊞ Win + S to open the search bar, type cmd and then click Command Prompt in the search results.
- For example, if you want to create a file on the Desktop, type cd desktop and 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:UsersNameDesktopFiles ).
- Type type nul > filename.txt .
- Replace filename.txt with the filename and extension you like. Other common extensions include “.docx” (Word document), “.png” (empty image file), “.xlsx” (Excel document), and “.rtf” (for text) basic format).
- Press ↵ Enter .
- Type copy con testfile .txt , but replace testfile with the filename you like.
- Press ↵ Enter .
- Enter the content you like. This is a rudimentary text editor, but still effective for coding or taking quick notes. You can use the Enter key while editing to enter text on the next line if you like.
- Press Ctrl + Z when you are done editing the file. This is the operation to save all the content entered into the file.
- Another way to do this is to enter the echo command here > filename .txt .
- fsutil file createnew filename .txt 1000 .
- Replace filename with the name you want, and replace 1000 with the number of bytes to create for the file.
Delete files
- Right-click the Start menu and select Command Prompt .
- Press ⊞ Win + S to open the search bar, type cmd and then click Command Prompt in the search results.
- For example, if you want to create a file on the Desktop, type cd desktop and 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:UsersNameDesktopFiles ).
- 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.
- For example, to delete a text file named “hello”, you would type del hello.txt into the Command Prompt.
- If the filename has spaces (eg “hi there”), enclose the filename in quotes (such as del "hi there" ).
- If you get a message that the file cannot be deleted, use the command del /f filename instead , as this command is used to delete read-only files.
Warning
- 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.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 41,397 times.
This is an article that shows you how to use Command Prompt on Windows to create and delete files and folders (also known as directories). Files that you create from the Command Prompt can be edited and managed using Windows applications, including File Manager and text editors.
Thank you for reading this post How to Create and Delete Files or Folders from Windows Command Prompt at Lassho.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search: