In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you how to delete the most stubborn files and folders on your computer in windows. The content is simple and easy to understand. It is clearly organized. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article about how to delete the most stubborn files and folders on your computer in windows.
Some folders and files cannot be deleted with Windows Explorer. These include files with long paths, names, or reserved names, such as CON, AUX, COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, PRN, NUL, etc. Even if you are an administrator, when you try to delete these files using Windows Explorer, you will receive an "Access denied" error message. In this case, you can only use the command line to forcibly delete them.
By default, Windows 10 comes with two command-line interfaces built in: Command Prompt and PowerShell, both of which will be used to remove unwanted content from your computer.
How to delete files and folders using Command Prompt
It is recommended that you use an administratively privileged command prompt to avoid any other possible prompts.
1. Execute Del/Erase command in cmd
The Del and Erase commands in the command prompt are aliases for each other, and no matter which command you use, both perform the same function and can be used to delete a single item (file) in the current working directory. Keep in mind that it cannot be used to delete directories (folders) themselves.
Use one of two commands:
Del File/Folder Name
Erase File/Folder Name
Replace the file/folder name with the name of the item you want to delete.
If you try to delete an item from a folder (whether empty or not), you will be prompted to confirm, in which case you will need to enter Y(yes) and N(no) to confirm. If you select Yes, the items in the folder will be deleted directly, but the directory (folder) will remain. However, the subdirectories within that folder will not change at all.
In order to delete everything in a folder and its subdirectories, you will need to add the/s option to the command.
2. rmdir /rd command in cmd
Like Del and Erase, rmdir and rd are aliases for each other, indicating deletion of directories. These commands delete entire directories and subdirectories, including the contents of directories.
rmdir"new folder"
The above command will delete the New Folder only if it is empty. If the folder contains subdirectories, the following "Directory is not empty" prompt might appear, in which case we would need to apply the/s option to delete items, just as we did earlier with the Del command.
rmdir /s"Final Folder"
Of course, you can also use the/q option to do this, this command will automatically delete, do not prompt you to confirm.
rmdir / s / q"Final Folder"
3. Delete multiple files and folders
So far, we have completed the task of deleting a single item per command. Now, let's see how to delete multiple files or folders.
For documents:
Del" File1.txt"" File3.txt"" File5.txt"
For catalogues:
rd" Folder1"" Folder3"" Folder5"
Mass deletion of files can also be performed with the Del command using an asterisk (*) with the file type or file name. However, Microsoft removed support for using asterisks for rmdir so that users would not accidentally delete entire folders.
Here is an example of how we delete all.txt files from our current working directory:
Del" * .txt"
4. Delete files and folders from any directory
Simply put the full path of the item you want to delete in parentheses to delete it, as shown in the following example:
rmdir "d:\test1\test2 folder\folder2"
5. Check if the file or folder exists and delete it using the IF command
We can view the contents of the working directory by typing Dir at the command prompt, but you can apply an "if" condition at the command prompt to delete an item. The method is as follows:
if exist File/FolderName (rmdir /s/q File/FolderName)
Replace File/FolderName in both locations with the name (and extension) of the item you want to delete. Here's an example:
if exist Desktop (rmdir /s/q Desktop) 2. How to delete files and folders using Windows PowerShell
The command used to delete content from a PC in Windows PowerShell is very similar to the Command Prompt command, with some other aliases. The overall function and logic are the same.
It is recommended that you "Run as Administrator"Windows PowerShell before continuing.
Note here that, unlike command prompt, all commands can be used for two purposes: deleting individual files as well as entire directories. So be careful when using PowerShell to delete files and folders, as the directories themselves are deleted as well.
If the directory contains subdirectories, PowerShell will confirm that you want to proceed with the delete operation, which will also include all child objects.
The following is a list of all commands/aliases that can be used to delete items in PowerShell:
Del
Rm-dir
remove-item
Erase
Rd
Ri
Rm
We tested all of these commands in the working directory, and each successfully deleted folders as well as individual items.
You can delete items through PowerShell using any of the following commands:
Del File/FolderName
Rm-dir File/FolderName
remove-item File/FolderName
Erase File/FolderName
Rd File/FolderName
Ri File/FolderName
Rm File/FolderName
1. Delete multiple files and folders
You can also delete multiple selected files and folders, just as we do when using the command prompt. The only difference is that you need to provide the full path for each project, even if it is in the same working directory. Use the following command:
Del "DriveLetter:\Path\ItemName", "DriveLetter:\Path\ItemName"
If the project is not a directory (.txt,.png, etc.), remember to attach file types.
You can also use an asterisk (*) to concatenate file types or file names, and use the Del command to perform bulk deletion of files, as you do at the command prompt.
2. Delete files and folders from any directory
You can also delete items in other directories just as you would in a command prompt. Simply enter the full path to the project in PowerShell, as follows:
Del "DriveLetter:\Path\ItemName", "DriveLetter:\Path\ItemName" III. Delete files and folders with complex and long paths using the command line
Sometimes, you may encounter errors when trying to delete items, either because the path is too long or because the item is buried too deep to delete. Here's a neat trick you can use both Command Prompt and PowerShell to empty the folder and then delete it using any of the methods above.
Use the following command to copy the contents of a folder (empty) into a folder that cannot be deleted. This will also leave the destination folder empty, making it movable.
robocopy "D:\EmptyFolder" D:\FolderToRemove /MIR
In this case, EmptyFolder is the source folder that we intentionally left empty in order to copy it to the destination folder "FolderToRemove."
Now, you will see that the previously unmovable folder is now empty. You can continue to delete it using any of the methods discussed in this article.
The above is "how to delete the most stubborn files and folders on the computer in windows" all the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.