How to Force Delete a Folder on Windows 10 and 11
Reference:
https://www.howtogeek.com/811409/force-delete-folder-windows/
How to Force Delete a Folder on Windows 10 and 11
MAHESH MAKVANA
@maheshhari
JUN 28, 2022, 1:00 PM EST | 3 MIN READ
Windows 11 and 10 desktop backgrounds.
Are you having trouble deleting a folder from your Windows 10 or Windows 11 PC? If so, that may be a system folder or a folder being used by other apps. We’ll show you how to successfully delete “undeletable” folders on your computer.
RELATED: How to Delete, Move, or Rename Locked Files in Windows
Table of Contents
Reasons You Can't Delete a Folder on Windows
Method 1: Use Command Prompt
Method 2: Boot in Windows Safe Mode
Method 3: Use Third-Party Software
Method 4: Use WinRAR to Force Remove Folders
Reasons You Can’t Delete a Folder on Windows
The most common reason you can’t delete a folder is that your folder is a Windows system folder. In this case, the system prevents you from removing the folder as it can make your PC unstable.
What Is A Windows System File?
RELATED
What Is A Windows System File?
If you’re sure yours is not a system folder, then your “undeletable” folder may be in use by your installed apps. When a folder is being used by an app, Windows prevents you from making changes to that folder. In this case, you can close the app using your folder and then try to delete the folder.
If your case doesn’t match either of the above scenarios, you may want to use one of the following methods to force remove your folder.
Method 1: Use Command Prompt
One quick way to force delete a folder is to use Command Prompt. You can run a command from this tool that deletes your selected folder.
To do that, first, open your “Start” menu and search for “Command Prompt”. Then, on the right pane, click “Run as Administrator.”
Select "Run as Administrator" on the right.
You’ll see a “User Account Control” prompt. Select “Yes.”
When Command Prompt opens, type the following command and press Enter. In this command, replace PATH with the path to the folder you want to delete.
Tip: If your path has spaces in it, enclose the path with double quotes.
rmdir /s /q PATH
Advertisement
For example, to delete a folder named Unwanted in the Documents folder on your C drive, you’d use the following command.
Warning: The command permanently deletes your folder, so make sure you really want to do that.
rmdir /s /q C:\Documents\Unwanted
Type the command and press Enter.
The specified folder is now removed from your Windows PC, and you’re all set.
THE BEST TECH NEWSLETTER ANYWHERE
Join 425,000 subscribers and get a daily digest of features, articles, news, and trivia.
e-mail address
Sign Me Up!
By submitting your email, you agree to the Terms of Use and Privacy Policy.
Method 2: Boot in Windows Safe Mode
If you aren’t sure what app has hijacked your folder so you can’t delete it, reboot your PC in safe mode and then try to delete the folder. In safe mode, your PC only loads the essential Windows files, preventing any third-party apps from automatically launching.
To use this method, first, boot your Windows 10 or Windows 11 PC in safe mode using our guide.
Once you’re in safe mode, launch File Explorer and locate the folder to delete. Then, right-click this folder and choose “Delete.”
Your folder is now deleted.
You may want to remove the folder from Recycle Bin as well, which you can do by opening the Recycle Bin, right-clicking your folder, and choosing “Delete.”
And that’s all there is to getting rid of stubborn folders on your PC. Enjoy!
Method 3: Use Third-Party Software
If your folder still won’t delete, there’s a free third-party app called Unlocker that can help you remove your folders. This app basically unlocks your folder from any locks due to which it can’t be deleted, and then allows you to finally get rid of the folder.
Advertisement
To use this method, first, download and install the free Unlocker app on your PC. Then launch the newly installed app.
On Unlocker’s main window, choose the folder to delete. Then, at the bottom, click “OK.”
On the screen that follows, click the drop-down menu and select “Delete.” Then click “OK.”
Unlocker will unlock your folder and delete it from your PC. You’re all done.
Method 4: Use WinRAR to Force Remove Folders
This might sound strange but you can use WinRAR (a file compression app) to delete your stubborn folders. The way this works is that you create an archive out of your “undeletable” folder and then ask the app to delete the original folder after the archive is made.
Advertisement
That way, when WinRAR has created an archive from your folder, it deletes the original folder. You can then delete the newly-created archive as well.
To do that, first, grab the free version of WinRAR and install it on your PC. Then restart your Windows 10 or Windows 11 PC so WinRAR integrates with your context menu.
When your PC turns back on, open File Explorer and find the folder to delete. Then right-click this folder and choose “Add to Archive.”
On the “Archive Name and Parameters” window, in the “Archiving Options” section, enable the “Delete Files After Archiving” option. Then, at the bottom of the window, select “OK.”
Let WinRAR make an archive from your selected folder. When that’s done, WinRAR will remove the original folder. At this point, you may now delete your newly created archive.
And that’s how you go about ridding your Windows PC of any unwanted and stubborn folders. Very useful!
While you’re at it, consider clearing your Windows PC’s cache to get rid of unwanted files from your storage.
RELATED: How to Clear Your Cache on Windows 11
------------------
cmd Delete Folder – How to Remove Files and Folders in Windows
https://www.freecodecamp.org/news/cmd-delete-folder-how-to-remove-files-and-folders-in-windows/
cmd Delete Folder – How to Remove Files and Folders in Windows
Kris Koishigawa
Kris Koishigawa
cmd Delete Folder – How to Remove Files and Folders in Windows
Sometimes it's just faster to do things with the command line.
In this quick tutorial we'll go over how to open Command Prompt, some basic commands and flags, and how to delete files and folders in Command Prompt.
If you're already familiar with basic DOS commands, feel free to skip ahead.
How to open Command Prompt
To open Command Prompt, press the Windows key, and type in "cmd".
Then, click on "Run as Administrator":
Screenshot showing how to open Command Prompt as an administrator
After that, you'll see a Command Prompt window with administrative privileges:
command-prompt-new-window
Screenshot of Command Prompt window
If you can't open Command Prompt as an administrator, no worries. You can open a normal Command Prompt window by clicking "Open" instead of "Run as Administrator".
The only difference is that you may not be able to delete some protected files, which shouldn't be a problem in most cases.
How to delete files with the del command
Now that Command Prompt is open, use cd to change directories to where your files are.
I've prepared a directory on the desktop called Test Folder. You can use the command tree /f to see a, well, tree, of all the nested files and folders:
Screenshot after running tree /f in target directory
To delete a file, use the following command: del "<filename>".
For example, to delete Test file.txt, just run del "Test File.txt".
There may be a prompt asking if you want to delete the file. If so, type "y" and hit enter.
Note: Any files deleted with the del command cannot be recovered. Be very careful where and how you use this command.
After that, you can run tree /f to confirm that your file was deleted:
Screenshot after deleting file with del command
Also, bonus tip – Command Prompt has basic autocompletion. So you could just type in del test, press the tab key, and Command Prompt will change it to del "Test File.txt".
How to force delete files with the del command
Sometimes files are marked as read only, and you'll see the following error when you try to use the del command:
Screenshot of error after trying to delete a read only file
To get around this, use the /f flag to force delete the file. For example, del /f "Read Only Test File.txt":
Screenshot after deleting file with the force flag
How to delete folders with the rmdir command
To delete directories/folders, you'll need to use the rmdir or rd command. Both commands work the same way, but let's stick with rmdir since it's a bit more expressive.
Also, I'll use the terms directory and folder interchangeably for the rest of the tutorial. "Folder" is a newer term that became popular with early desktop GUIs, but folder and directory basically mean the same thing.
To remove a directory, just use the command rmdir <directory name>.
Note: Any directories deleted with the rmdir command cannot be recovered. Be very careful where and how you use this command.
In this case I want to remove a directory named Subfolder, so I'll use the command rmdir Subfolder:
Screenshot of a directory not empty error
But, if you remember earlier, Subfolder has a file in it named Nested Test File.
You could cd into the Subfolder directory and remove the file, then come back with cd .. and run the rmdir Subfolder command again, but that would get tedious. And just imagine if there were a bunch of other nested files and directories!
Like with the del command, there's a helpful flag we can use to make things much faster and easier.
How to use the /s flag with rmdir
To remove a directory, including all nested files and subdirectories, just use the /s flag:
Screenshot after running rmdir with the /s flag
There will probably be a prompt asking if you want to remove that directory. If so, just type "y" and hit enter.
And that's it! That should be everything you need to know to remove files and folders in the Windows Command Prompt.
All of these commands should work in PowerShell, which is basically Command Prompt version 2.0. Also, PowerShell has a bunch of cool aliases like ls and clear that should feel right at home if you're familiar with the Mac/Linux command line.
Did these commands help you? Are there any other commands that you find useful? Either way, let me know over on Twitter.
-------------
del
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/del
Article
06/22/2022
2 minutes to read
10 contributors
Deletes one or more files. This command performs the same actions as the erase command.
The del command can also run from the Windows Recovery Console, using different parameters. For more information, see Windows Recovery Environment (WinRE).
Warning
If you use del to delete a file from your disk, you can't retrieve it.
Syntax
Copy
del [/p] [/f] [/s] [/q] [/a[:]<attributes>] <names>
erase [/p] [/f] [/s] [/q] [/a[:]<attributes>] <names>
Parameters
Parameter Description
<names> Specifies a list of one or more files or directories. Wildcards may be used to delete multiple files. If a directory is specified, all files within the directory will be deleted.
/p Prompts for confirmation before deleting the specified file.
/f Forces deletion of read-only files.
/s Deletes specified files from the current directory and all subdirectories. Displays the names of the files as they are being deleted.
/q Specifies quiet mode. You are not prompted for delete confirmation.
/a[:]<attributes> Deletes files based on the following file attributes:
r Read-only files
h Hidden files
i Not content indexed files
s System files
a Files ready for archiving
l Reparse points
- Used as a prefix meaning 'not'
.
/? Displays help at the command prompt.
Remarks
If you use the del /p command, you'll see the following message:
FileName, Delete (Y/N)?
To confirm the deletion, press Y. To cancel the deletion and to display the next file name (if you specified a group of files), press N. To stop the del command, press CTRL+C.
If you disable command extension, the /s parameter will display the names of any files that weren't found ,instead of displaying the names of files that are being deleted.
If you specify specific folders in the <names> parameter, all of the included files will also be deleted. For example, if you want to delete all of the files in the \work folder, type:
Copy
del \work
You can use wildcards (* and ?) to delete more than one file at a time. However, to avoid deleting files unintentionally, you should use wildcards cautiously. For example, if you type the following command:
Copy
del *.*
The del command displays the following prompt:
Are you sure (Y/N)?
To delete all of the files in the current directory, press Y and then press ENTER. To cancel the deletion, press N and then press ENTER.
Note
Before you use wildcard characters with the del command, use the same wildcard characters with the dir command to list all the files that will be deleted.
Examples
To delete all the files in a folder named Test on drive C, type either of the following:
Copy
del c:\test
del c:\test\*.*
To delete all the files in a folder where the folder has a space in its name, the full path needs to be wrapped in double quotes. Type either of the following:
Copy
del "c:\test folder\"
del "c:\test folder\*.*"
To delete all files with the .bat file name extension from the current directory, type:
Copy
del *.bat
To delete all read-only files in the current directory, type:
Copy
del /a:r *.*
Additional References
Command-Line Syntax Key
Windows Recovery Environment (WinRE)
Recommended content
rd
Reference article for the rd command, which deletes a directory.
goto
Reference article for the goto command, which directs cmd.exe to a labeled line in a batch program.
if
Reference article for the if command, which performs conditional processing in batch programs.
for
Reference article for the for command, which runs a specified command for each file, within a set of files.
No comments:
Post a Comment