使用命令提示符删除文件夹或文件:(Delete a Folder or File using Command Prompt: )要在设备上创建或删除文件夹,您只需右键单击(right-click)桌面并选择所需的选项。这不是很容易吗?是的,这是一个非常简单的过程,但有时这种方法不起作用,或者您可能会遇到一些问题。所以这就是为什么你不需要依赖一种方法。您始终可以使用命令提示符(Command Prompt)( CMD ) 创建新文件夹或文件并删除文件夹或文件。在本指南中,我们将讨论创建或删除文件和文件夹的所有可能方法。
如果您无法删除某些文件或文件夹并且看到Windows警告消息,请不要担心,您可以使用命令提示符(Command Prompt)轻松删除此类文件夹或文件。因此(Therefore),学习使用命令提示符(Command Prompt)执行某些任务总是有帮助的。我们将讨论Microsoft用户创建和删除文件或文件夹的所有方式。
注意:(Note: )如果您删除一个文件夹,那么它也将删除其所有内容和文件。因此,您需要记住这一点,一旦使用命令提示符(Command Prompt)删除文件夹,您将删除所选文件夹中存在的所有文件。
删除键(Delete Key)
删除文件夹或文件的最简单方法之一是选择特定文件夹或文件,然后按键盘上的删除按钮。(Delete)您只需要在您的设备上找到特定的文件或文件夹。如果要删除多个文件和文件夹,则需要按住Ctrl键并选择所有需要删除的文件或文件夹。完成后,再次按下键盘上的Delete按钮。(Delete)
使用右键单击选项删除文件夹或文件 (Delete folders or files with right-click option )
您可以选择要删除的文件或文件夹,然后右键单击该文件或文件夹,然后从右键单击上下文菜单中选择删除选项。
如何使用命令提示符删除(Command Prompt)文件夹(Folder)或文件(File)
确保 创建一个还原点(create a restore point)以防万一出现问题。
使用命令提示符(Command Prompt)删除、创建或打开任何文件或文件夹时,您需要确保使用正确的命令来完成任务。希望(Hopefully)您会发现下面提到的所有方法都有帮助。
方法 1:如何在 MS-DOS 命令提示符中删除文件或文件夹(Method 1: How to delete files or folders in MS-DOS Command Prompt)
注意:(Note:)您需要在您的设备上以管理员访问权限 打开命令(Command)提示符或Windows PowerShell 。
1.使用此处提到(methods mentioned here)的任何一种方法打开提升的命令提示符(Command Prompt)。
2.现在在命令提示符(Command Prompt)中键入以下命令并按Enter:
德尔示例.txt(Del example.txt)
3.您需要输入文件的完整路径( enter the full path)(位置)和文件名及其扩展名(file name with its extension)才能删除该文件。
例如,我从我的设备中删除了 sample.docx 文件。要删除,我输入了不带引号的“ del sample.docx ”。但首先,我需要使用 cd 命令导航到所述文件位置。
如何使用命令提示符删除文件夹或目录(How to delete a folder or directory using the Command Prompt)
1.再次使用此处提到(methods mentioned here)的任何一种方法打开提升的命令提示符(Elevated Command Prompt)。
2.现在您需要在 cmd 中输入以下命令并按Enter:
rmdir /s <complete path of folder>
3.如果您的文件夹路径有空格,那么您需要在路径中使用引号。
rmdir /s “C:\Users\suraj\Desktop\test folder”
4.举个例子来说明一下:我在我的D盘里创建了一个测试文件夹。要删除该文件夹,我需要输入以下命令:
rmdir /s d: \testfolder\
您需要键入保存文件夹的驱动器名称,然后键入所述文件夹的名称。键入上述命令并按Enter后,您的文件夹及其所有内容将从您的 PC 中永久删除,而不会在您的设备上留下任何痕迹。
既然您已经学习了如何使用命令提示符(Command Prompt)( CMD ) 删除文件夹或文件,您是否希望继续了解更多可以使用命令提示符(Command Prompt)执行的操作? 好吧(Well),如果您有兴趣,那么在下一部分中,我们将讨论如何创建文件夹,使用命令提示符(Command Prompt)打开任何文件夹和文件。
方法 2:如何使用命令提示符创建文件夹(Method 2: How to create a Folder using the Command Prompt)
1.使用此处提到(methods mentioned here)的任何一种方法打开提升的命令提示符(Command Prompt)。
2.现在在命令提示符(Command Prompt)中键入以下命令并按Enter:
MD drive_letter\folder name\
注意:(Note:)这里您需要将 drive_letter 替换为您要在其中创建所述文件夹的实际驱动器号。此外,您需要将文件夹名称替换为您希望使用的文件夹的实际名称。
3.在上面的例子中,我在我的电脑的 D: 驱动器(testfolder in the D: drive)中创建了一个测试文件夹,为此,我使用了以下命令:
MD D: \testfolder\
您可以在此处根据您的驱动器首选项和文件夹名称更改驱动器和文件夹名称。现在,您可以通过转到创建文件夹的驱动器来检查命令是否成功执行。就我而言,我在 D: 驱动器中创建了该文件夹。下图显示该文件夹是在我的系统上的 D: 驱动器下创建的。
如果要在设备上打开特定文件夹,也可以使用命令提示符(Command Prompt)来完成。
1.打开命令提示符(Command Prompt)并在 cmd 中键入以下给出( b)的(elow-given)命令:
start drive_name: \folder name
注意:(Note:)这里您需要将 drive_letter 替换为您希望打开的文件夹所在的实际驱动器号。此外,您需要将文件夹名称替换为您希望使用的文件夹的实际名称。
2.在上面的例子中,我打开了在上面步骤中创建的同一个文件夹(testfolder),为此,我使用了以下命令:
start D: \testfolder\
一旦您按下 Enter 按钮,该文件夹将立即在您的屏幕上打开,不会有任何延迟。欢呼!
使用命令提示符删除文件夹(Delete a folder with the Command Prompt)
虽然我们已经讨论了如何使用命令提示符(Command Prompt)删除文件夹,但是在这种方法中,我们将使用另一个命令。此命令对于删除设备上的文件夹也同样有用。
1.使用此处提到(methods mentioned here)的任何一种方法打开提升的命令提示符(Command Prompt)。
2.现在在命令提示符(Command Prompt)中键入以下命令并按Enter:
Rd drive_name: \folder name\
3.例如,我删除了我们在上面创建的同一个文件夹testfolder。为此,我使用以下命令:
Rd D: \testfolder\
点击 Enter 后,上述文件夹(testfolder)将立即从系统中删除。此文件夹将从您的系统中永久删除且无法恢复。删除后,您将无法在回收站(Recycle)中找到它来恢复。因此,您需要确保使用命令提示符(Command Prompt)删除任何文件或文件夹,因为一旦删除,您将无法恢复数据。
受到推崇的:(Recommended:)
我希望这篇文章对您有所帮助,现在您可以使用命令提示符 (CMD) 轻松删除文件夹或文件( Delete a Folder or File using Command Prompt (CMD)),但如果您对本教程仍有任何疑问,请随时在评论部分提出。
Delete a Folder or File using Command Prompt (CMD)
Delete a Folder or File using Command Prompt: To create or delete a folder on your device you can simply right-click on the desktop and choose the desired options. Isn’t it easy? Yes, it is a very easy process but sometimes this method doesn’t work, or you can face some problems. So that’s why you don’t need to rely on one single method. You can always use the Command Prompt (CMD) to create a new folder or file and delete folders or files. In this guide, we will discuss all the possible methods to create or delete files & folders.
If you are not able to delete some files or folders and you see a Windows warning message then don’t worry, you can easily delete such folders or files using the Command Prompt. Therefore, learning to use Command Prompt to perform certain tasks is always helpful. We will discuss all the ways via which Microsoft users can create & delete files or folders.
Note: If you delete a folder, then it will also delete all its contents & files. Therefore, you need to keep this in mind that once you delete a folder using Command Prompt, you will delete all the files present within the selected folder.
Delete Key
One of the easiest ways to delete a folder or file is to select the particular folder or file and then press the Delete button your keypad. You just need to locate the particular file or folder on your device. If you want to delete multiple files & folders then you need to press & hold the Ctrl key and select all the files or folders which you need to delete. Once done, then again press the Delete button on your keyboard.
Delete folders or files with right-click option
You can select the file or folder that you want to delete and right-click on that file or folder and choose the delete option from the right-click context menu.
How to Delete a Folder or File using Command Prompt
Make sure to create a restore point just in case something goes wrong.
While deleting, creating, or opening any file or folder using the Command Prompt, you need to make sure that you use the right command to get your task done. Hopefully, you will find all the below-mentioned methods helpful.
Method 1: How to delete files or folders in MS-DOS Command Prompt
Note: You need to open a Command prompt or Windows PowerShell with admin access on your device.
1.Open Elevated Command Prompt using any one of the methods mentioned here.
2.Now type the following command into the Command Prompt and hit Enter:
Del example.txt
3.You need to enter the full path (location) of the file and file name with its extension to delete that file.
For example, I deleted sample.docx file from my device. To delete I entered “del sample.docx” without quotation marks. But first, I need to navigate to the said file location using the cd command.
How to delete a folder or directory using the Command Prompt
1.Again open Elevated Command Prompt using any one of the methods mentioned here.
2.Now you need to enter the below-mentioned command into cmd and hit Enter:
rmdir /s <complete path of folder>
3.If your folder path has spaces, then you need to use quotation marks for the path.
rmdir /s “C:\Users\suraj\Desktop\test folder”
4.Let’s take an example for illustration purpose: I have created a test folder in my D drive. To delete that folder I need to enter the below command:
rmdir /s d: \testfolder\
You need to type the drive name where your folder is saved and then type the name of the said folder. Once you type the above command and hit Enter, your folder and all of its content will be deleted permanently from your PC without leaving any trace on your device.
Now that you have learned how to delete a folder or file using Command Prompt (CMD), do you wish to continue to learn more thing that you can do with the Command Prompt? Well, if you are interested then in the next part we will talk about how to create a folder, open any folder and file using the Command Prompt.
Method 2: How to create a Folder using the Command Prompt
1.Open Elevated Command Prompt using any one of the methods mentioned here.
2.Now type the following command into the Command Prompt and hit Enter:
MD drive_letter\folder name\
Note: Here you need to replace drive_letter with the actual drive letter where you want to create the said folder. And also, you need to replace the folder name with the actual name of the folder which you wish to use.
3.In the above example, I have created a testfolder in the D: drive of my PC and for that, I have used the command:
MD D: \testfolder\
Here you can change the drive and folder name according to your drive preferences and folder name. Now you can check whether the command successfully executed or not by going to the drive where you have created the folder. As in my case, I have created the folder in the D: drive. Below image shows that the folder is created under D: drive on my system.
If you want to open a particular folder on your device, you can do it using the Command Prompt as well.
1.Open the Command Prompt and type the below-given command in the cmd:
start drive_name: \folder name
Note: Here you need to replace drive_letter with the actual drive letter where your folder which you wish to open reside. And also, you need to replace the folder name with the actual name of the folder which you wish to use.
2.In the above example, I have opened the same folder (testfolder) that I created in the above step and for that, I have used the command:
start D: \testfolder\
Once you will hit the enter button, the folder will immediately open on your screen without a delay. Hurray!
Delete a folder with the Command Prompt
Although we have already discussed how to delete a folder with Command Prompt but in this method, we will use another command. This command is also equally useful to delete a folder on your device.
1.Open Elevated Command Prompt using any one of the methods mentioned here.
2.Now type the following command into the Command Prompt and hit Enter:
Rd drive_name: \folder name\
3.For example, I deleted the same folder which we created above, testfolder. For that, I use the following command:
Rd D: \testfolder\
Once you hit Enter, the above folder (testfolder) will be deleted immediately from your system. This folder will be permanently deleted from your system and cannot be recovered. Once deleted, you will not find it in the Recycle bin to restore. Therefore, you need to be sure while deleting any files or folders with Command Prompt as you won’t be able to recover the data once deleted.
Recommended:
I hope this article was helpful and now you can easily Delete a Folder or File using Command Prompt (CMD), but if you still have any questions regarding this tutorial then feel free to ask them in the comment’s section.