摆脱Windows 10上的任何文件就像吃馅饼一样容易。但是,在文件资源管理器(File Explorer)中执行的删除过程(deletion process)的持续时间因项目而异。影响它的各种因素是大小、要删除的单个文件的数量、文件类型等。因此,删除包含数千个单个文件的大型文件夹可能需要几个小时(can take hours)。在某些情况下,删除期间显示的估计时间甚至可能超过一天。此外,传统的删除方式也效率低下,因为您需要清空回收站( empty Recycle bin)才能从 PC 中永久删除这些文件。因此,在本文中,我们将讨论如何在Windows PowerShell中删除文件夹和子文件夹(Windows PowerShell)迅速地。
如何在 Windows PowerShell 中删除文件夹和子文件夹(How to Delete Folders and Subfolders in Windows PowerShell)
下面列出了删除文件夹的最简单方法:
- 选择项目并按键盘上的Del 键(key)。
- 右键单击该项目并从出现的上下文菜单中选择(from the context menu)删除(Delete) 。
但是,您删除的文件不会被 PC 永久删除,因为这些文件仍会存在于回收站(Recycle bin)中。因此(Hence),要从您的Windows PC中永久删除文件,
- 同时按下Shift + Delete keys可删除该项目。
- 或者,右键单击桌面上的(Desktop)回收站(Recycle bin)图标,然后单击清空回收站(Empty recycle bin)选项。
为什么要在 Windows 10 中删除大文件?(Why Delete Large Files in Windows 10?)
以下是在Windows 10(Windows 10)中删除大文件的一些原因:
- 您的 PC 上的磁盘空间(disk space)可能不足,因此需要清理空间。
- 您的文件或文件夹可能意外重复(duplicated)
- 可以删除您的私人或敏感文件,以便其他人无法访问这些文件。(private or sensitive files)
- 由于恶意程序的攻击,您的文件可能已损坏或充满恶意软件。(corrupt or full of malware)
删除大文件和文件夹的问题(Issues With Deleting Large Files and Folders)
有时,当您删除较大的文件或文件夹时,您可能会遇到烦人的问题,例如:
-
无法删除文件(Files can’t be deleted)- 当您尝试删除应用程序文件和文件夹而不是卸载它们时会发生这种情况。
-
删除持续时间很长(Very long duration of deletion)- 在开始实际删除过程(deleting process)之前,文件资源管理器(File Explorer)会检查文件夹的内容并计算文件总数以提供ETA。除了(Apart)检查和计算之外,Windows还分析文件以显示当时正在删除的文件/文件夹的更新。这些额外的进程对整个删除操作周期(operation period)有很大贡献。
必读(Must Read):什么是 HKEY_LOCAL_MACHINE?
幸运的是,有几种方法可以绕过这些不必要的步骤并加快从Windows 10删除大文件的过程。在本文中,我们将向您介绍执行相同操作的各种方法。
方法 1:在 Windows PowerShell 中删除文件夹和子文件夹(Method 1: Delete Folders and Subfolders in Windows PowerShell)
按照下面提到的步骤使用PowerShell 应用程序(PowerShell app)删除大文件夹:
1.点击开始(Start)并输入powershell,然后点击以管理员身份运行(Run as administrator)。
2. 键入以下命令(command) 并按Enter 键(Enter key)。
Remove-Item -path C:\Users\ACER\Documents\large_folders -recurse
注意:(Note:)将上述命令中的路径(path)更改为您要删除的文件夹路径。(folder path)
另请阅读:(Also Read:)如何在Windows 10中(Windows 10)删除 Win 安装文件(Delete Win Setup Files)
方法 2:在(Method 2: )命令提示符(Command Prompt)中删除文件夹和子文件夹(Delete Folders and Subfolders in)
根据微软官方文档(Microsoft documentation),del 命令(del command)删除一个或多个文件,rmdir 命令(rmdir command)删除文件目录。这两个命令也可以在Windows 恢复环境(Windows Recovery Environment)中运行。以下是在命令提示符(Command Prompt)中删除文件夹和子文件夹的方法:
1. 按Windows + Q keys启动搜索栏(search bar)。
2. 键入命令提示符( Command Prompt)并单击右窗格中的以管理员身份运行(Run as Administrator)选项。
3.如果出现提示,请在“用户帐户控制(User Account Control)”弹出窗口中单击“是”。(Yes)
4. 键入cd和要删除的文件夹路径,然后(folder path)按 Enter 键(Enter key)。
例如,cd C:\Users\ACER\Documents\Adobe如下图所示。
注意:(Note:)您可以从文件资源管理器应用程序复制(File Explorer)文件夹路径(folder path),以免出错。
5.命令行(command line)现在将反映文件夹路径(folder path)。交叉检查一次以确保输入的路径删除正确的文件。然后,键入以下命令 (command )并按Enter 键(Enter key)执行。
del /f/q/s *.* > nul
6. 键入cd 。. 命令在文件夹路径(folder path and hit) 中返回一步并按Enter 键(Enter key)。
7. 键入以下命令(command) 并按Enter删除指定的文件夹。
rmdir /q/s FOLDER_NAME
将FOLDER_NAME(FOLDER_NAME)更改为要删除的文件夹的名称。
这是在命令提示符(Command Prompt)中删除大文件夹和子文件夹的方法。
另请阅读:(Also Read:)如何在Windows 10中(Windows 10)强制删除文件(Force Delete File)
方法 3:在上下文菜单中添加快速删除选项(Method 3: Add Quick Delete Option in Context Menu)
虽然,我们已经学习了如何在Windows PowerShell 或命令提示符(Windows PowerShell or Command Prompt)中删除文件夹和子文件夹,但需要对每个单独的大文件夹重复该过程。为了进一步简化这一点,用户可以创建命令的批处理文件(batch file),然后将该命令添加到文件资源管理器(File Explorer)上下文菜单( context menu)中。它是右键单击文件/文件夹后出现的菜单。然后,资源管理器(Explorer)中的每个文件和文件夹(file and folder)都可以使用快速删除选项(delete option),供您选择。这是一个漫长的过程,因此请仔细遵循。
1. 同时按下Windows + Q keys并输入记事本。(notepad.)然后点击打开(Open),如图。
2.仔细复制并粘贴(Carefully copy and paste)记事本(Notepad)文档中的给定行,如图所示:
@ECHO OFF
ECHO Delete Folder: %CD%?
PAUSE
SET FOLDER=%CD%
CD /
DEL /F/Q/S "%FOLDER%" > NUL
RMDIR /Q/S "%FOLDER%"
EXIT
3. 单击左上角的(left corner)文件(File )选项,然后从菜单中选择另存为...。( Save As…)
4. 键入quick_delete.bat作为文件名:(File name: )并单击保存(Save)按钮。
5. 转到文件夹位置(Folder location)。右键单击quick_delete.bat文件并选择突出显示的复制(Copy )。
6.在文件资源管理器(File Explorer. )中转到C:\Windows按Ctrl + V keys 将quick_delete.bat文件粘贴到此处。
注意:(Note: )为了添加快速删除选项(delete option),quick_delete.bat 文件(quick_delete.bat file)需要位于具有自己的PATH 环境(PATH environment)变量的文件夹中。Windows 文件夹(Windows folder)的路径变量(path variable)是%windir%.
7. 同时按Windows + R 键(keys)启动运行(Run)对话框。
8. 键入regedit并按Enter打开注册表编辑器( Registry Editor)。
注意:(Note: )如果您不是从管理员帐户(administrator account)登录,您将收到一个用户帐户控制(User Account Control)弹出请求权限。单击(Click)“是”(Yes )授予它并继续执行后续步骤以删除文件夹和子文件夹。
9.如下图所示,转到HKEY_CLASSES_ROOT\Directory\shell
10. 右键单击 shell文件夹。在上下文菜单(context menu)中单击New> 键(Key )。将此新键重命名为Quick Delete。
11. 右键单击快速删除(Quick Delete)键,转到新建,( New, )然后从菜单中选择键( Key ),如下图所示。
12. 将新键(new key)重命名为Command。
13. 在右窗格中,双击(默认)((Default))文件以打开编辑字符串(Edit String)窗口。
14.在数值数据(Value Data: )下cmd /c “cd %1 && quick_delete.bat” :然后点击确定(OK)
快速删除选项(Delete option)现已添加到资源管理器上下文(Explorer context)菜单中。
15. 关闭注册表编辑器(Registry Editor)应用程序并返回您要删除的文件夹。(Folder)
16. 右键单击文件夹(folder)并从上下文菜单中选择“快速删除”,如图所示。(Quick Delete)
选择Quick Delete后,将出现一个命令提示窗口(command prompt window),要求确认操作。
17. 交叉检查文件夹路径(Folder path)和文件夹名称(Folder name)一次,然后单击键盘上的任意键(any key )快速删除文件夹。
注意:(Note: )但是,如果您不小心选择了错误的文件夹并想终止进程,请按Ctrl + C。命令提示符(command prompt)将再次通过显示消息Terminate batch job (Y/N)?按Y然后按Enter取消快速删除操作(Quick Delete operation),如下图所示。
另请阅读:(Also Read:)如何删除Windows 注册表(Windows Registry)中的损坏条目(Delete Broken Entries)
专业提示:(Pro Tip:) 参数表(Table of Parameters) 及其用途
(& their Uses
)
Parameter |
Function/Use |
/f |
Forcefully deletes read-only files |
/q |
Enables quiet mode, you do not need to confirm for every deletion |
/s |
Executes the command on all files in folders of the specified path |
*.* |
Deletes all the files in that folder |
nul |
Speeds up the process by disabling console output |
执行del /?命令以了解更多信息。
推荐的:(Recommended:)
- Microsoft Store(Microsoft Store Install Games)在哪里安装游戏?
- 如何修复(Fix PDFs)无法(Chrome)在Chrome中打开的 PDF(Opening)
- 如何禁用谷歌软件报告工具(Google Software Reporter Tool)
- 如何在Windows 10上添加(Windows 10)Notepad++ Plugin
以上方法是在 Windows 10(delete large folders in Windows 10)中删除大文件夹最有效的方法。我们希望本指南帮助您了解如何在 PowerShell 和命令提示符中删除文件夹和子文件夹(how to delete folders and subfolders in PowerShell & Command Prompt)。此外,如果您对本文有任何疑问/评论,请随时将它们放在评论部分。
How to Delete Folders and Subfolders in PowerShell
Getting rid of any file on Windows 10 is as easy as eating pie. However, the duration of the deletion process execυtеd іn File Explorer varieѕ from item to itеm. The various factors that influence it are size, number of іndividual files to be deleted, file type, etc. Thus, deleting large folders containing thousands of individuаl files can take hours. In some cases, the estimated time displayed during deletion can even be more than a single day. Moreover, the traditional way of deleting is also slightly inefficient as you will need to empty Recycle bin to permanently remove these files from your PC. So, in this article, we will discuss how to delete folders and subfolders in Windows PowerShell quickly.
How to Delete Folders and Subfolders in Windows PowerShell
The simplest ways of deleting a folder are listed below:
- Select the item and press the Del key on the keyboard.
- Right-click on the item and select Delete from the context menu that appears.
However, the files that you delete are not permanently deleted by the PC, since the files will still be present in the Recycle bin. Hence, to remove files permanently from your Windows PC,
- Either press Shift + Delete keys together to delete the item.
- Or, right-click Recycle bin icon on the Desktop & then, click Empty recycle bin option.
Why Delete Large Files in Windows 10?
Here are some reasons to delete large files in Windows 10:
- The disk space on your PC might be low, so it is required to clear out space.
- Your files or folder might have duplicated accidentally
- Your private or sensitive files can be deleted so that no one else can access these.
- Your files might be corrupt or full of malware due to attack by malicious programs.
Issues With Deleting Large Files and Folders
Sometimes, when you delete larger files or folders you might face annoying issues like:
-
Files can’t be deleted – This happens when you try to delete application files and folders instead of uninstalling them.
-
Very long duration of deletion – Before starting the actual deleting process, the File Explorer checks the contents of the folder & calculates the total number of files to provide an ETA. Apart from checking and calculating, Windows also analyzes the files in order to display updates on the file/folder that is being deleted at that moment. These additional processes contribute greatly to the overall delete operation period.
Must Read: What is HKEY_LOCAL_MACHINE?
Fortunately, there are a few ways to bypass these unnecessary steps and speed up the process to delete large files from Windows 10. In this article, we will walk you through various methods of doing the same.
Method 1: Delete Folders and Subfolders in Windows PowerShell
Follow the steps mentioned below to delete large folders using PowerShell app:
1. Click on Start and type powershell, then click on Run as administrator.
2. Type the following command and hit the Enter key.
Remove-Item -path C:\Users\ACER\Documents\large_folders -recurse
Note: Change the path in the above command to the folder path which you want to delete.
Also Read: How to Delete Win Setup Files in Windows 10
Method 2: Delete Folders and Subfolders in Command Prompt
According to official Microsoft documentation, the del command deletes one or more files and the rmdir command deletes file directory. Both of these commands can also be run in the Windows Recovery Environment. Here’s how to delete folders and subfolders in Command Prompt:
1. Press Windows + Q keys to launch the search bar.
2. Type Command Prompt and click the Run as Administrator option in the right pane.
3. Click Yes in the User Account Control pop-up, if prompted.
4. Type cd and the folder path you want to delete and hit Enter key.
For example, cd C:\Users\ACER\Documents\Adobe as shown below.
Note: You can copy the folder path from the File Explorer application so that there are no mistakes.
5. The command line will now reflect the folder path. Cross-check it once to ensure the entered path to delete the correct files. Then, type the following command and hit Enter key to execute.
del /f/q/s *.* > nul
6. Type cd . . command to go back one step in the folder path and hit Enter key.
7. Type the following command and hit Enter to delete the folder specified.
rmdir /q/s FOLDER_NAME
Change the FOLDER_NAME with the name of the folder which you want to delete.
This is how to delete large folders and subfolders in Command Prompt.
Also Read: How to Force Delete File in Windows 10
Method 3: Add Quick Delete Option in Context Menu
Although, we have learned how to delete folders and subfolders in Windows PowerShell or Command Prompt, the procedure needs to be repeated for every individual large folder. To ease this further, users can create a batch file of the command and then add that command to File Explorer context menu. It is the menu that appears after you right-click on a file/folder. A quick delete option will then be available for every file and folder within the Explorer for you to choose from. This is lengthy procedure, so follow it carefully.
1. Press Windows + Q keys together and type notepad. Then click Open as shown.
2. Carefully copy and paste the given lines in the Notepad document, as depicted:
@ECHO OFF
ECHO Delete Folder: %CD%?
PAUSE
SET FOLDER=%CD%
CD /
DEL /F/Q/S "%FOLDER%" > NUL
RMDIR /Q/S "%FOLDER%"
EXIT
3. Click the File option from the top left corner and choose Save As… from the menu.
4. Type quick_delete.bat as File name: and click the Save button.
5. Go to Folder location. Right-click quick_delete.bat file and choose Copy shown highlighted.
6. Go to C:\Windows in File Explorer. Press Ctrl + V keys to paste the quick_delete.bat file here.
Note: In order to add the quick delete option, the quick_delete.bat file needs to be in a folder that has a PATH environment variable of its own. The path variable for the Windows folder is %windir%.
7. Press Windows + R keys simultaneously to launch Run dialog box.
8. Type regedit and hit Enter to open the Registry Editor.
Note: If you are not logged in from an administrator account, you will receive a User Account Control pop-up requesting permission. Click on Yes to grant it and continue the next steps to delete folders and subfolders.
9. Go to HKEY_CLASSES_ROOT\Directory\shell as depicted below.
10. Right-click on shell folder. Click New> Key in the context menu. Rename this new key as Quick Delete.
11. Right-click on the Quick Delete key, go to New, and choose Key from the menu, as illustrated below.
12. Rename the new key as Command.
13. On the right pane, double-click on the (Default) file to open the Edit String window.
14. Type cmd /c “cd %1 && quick_delete.bat” under Value Data: and click OK
The quick Delete option has now been added to the Explorer context menu.
15. Close the Registry Editor application and go back to the Folder you wish to delete.
16. Right-click on the folder and choose Quick Delete from the context menu, as shown.
As soon as you select Quick Delete, a command prompt window will appear requesting confirmation of the action.
17. Cross-check the Folder path and the Folder name once and click any key on the keyboard to delete the folder quickly.
Note: However, if you accidentally selected the wrong folder and would like to terminate the process, press Ctrl + C. The command prompt will again ask for confirmation by displaying the message Terminate batch job (Y/N)? Press Y and then hit Enter to cancel the Quick Delete operation, as depicted below.
Also Read: How to Delete Broken Entries in Windows Registry
Pro Tip: Table of Parameters & their Uses
Parameter |
Function/Use |
/f |
Forcefully deletes read-only files |
/q |
Enables quiet mode, you do not need to confirm for every deletion |
/s |
Executes the command on all files in folders of the specified path |
*.* |
Deletes all the files in that folder |
nul |
Speeds up the process by disabling console output |
Execute del /? command to learn more on the same.
Recommended:
The above methods are the most effective methods to delete large folders in Windows 10. We hope that this guide helped you to learn how to delete folders and subfolders in PowerShell & Command Prompt. Also, if you have any queries/comments regarding this article, feel free to drop them in the comments section.