Luckily it's not too hard to deal with
Does Microsoft Windows display a “The Directory Is Not Empty” error when you try to delete a folder? Your folder may be locked, or you may not have the required permission to remove the folder. You can follow a few easy methods to fix this problem and delete your folder successfully.
Some reasons you may not be able to remove your folder is that File Explorer is experiencing a minor glitch, your disk has a bad sector, you don’t have permission to remove the folder, or Windows’ system files are corrupt.
Restart File Explorer
When you get a “The Directory Is Not Empty” error, an easy fix you can apply to fix your issue is to restart File Explorer. Doing so resolves any minor problems with your file manager utility, allowing you to delete your items without any problems.
- Right-click the Windows taskbar and choose Task Manager.
- Right-click Windows Explorer on the list and select Restart.
- Try to delete your folder.
Renaming Your Folder to Resolve the Issue
If you still can’t delete your folder, give your folder a new name, and then try to remove the item. This method should resolve the issue if a minor system glitch is causing the problem.
- Right-click the problematic folder and choose Rename. Alternatively, select the folder and press F2 on your keyboard.
- Enter a new name for your folder and press the Enter key.
- Right-click the folder and choose Delete.
Delete the Folder Using the Free Unlocker App
If you still can’t remove your folder, that may be because an app or service on your computer is using that folder. In this case, you can use a free app called Unlocker to remove all locking handles from your folder and delete the folder.
- Download and install the free Unlocker app on your PC.
- Launch the app and select Yes in the User Account Control prompt.
- Choose your problematic folder on the list and select OK.
- Unlocker will display the items locking your folder.
- Choose Delete from the drop-down menu and select OK.
Delete Files Using Command Prompt
Command Prompt is a good alternative to use when you can’t use File Explorer to remove items. You can use a command in this command-line utility to remove your chosen folder from your storage.
- Open the Start menu, find Command Prompt, and select Run as administrator.
- Choose Yes in the User Account Control prompt.
- Type the following command in CMD and press Enter. Here, replace PATH with the full path to the folder you want to delete.
rmdir /s “PATH”
Check Disk for Bad Sectors to Fix the Empty Error
The hard disk where you’ve stored your folder may have a bad sector, preventing you from deleting your items. In this case, use Windows’ built-in CHKDSK command to find and fix bad sectors on your disk.
- Open Start, locate Command Prompt, and select Run as administrator.
- Choose Yes in the User Account Control prompt.
- Type the following command in CMD and press Enter. Here, replace C with the drive where you’ve stored the folder.
CHKDSK /F C:
- Type Y on your keyboard and press Enter to unmount the drive.
- If you see a message asking you to schedule the fix on the next reboot, type Y and press Enter.
- Restart Windows, and CHKDSK will kick in to fix any bad items on your disk.
Get Full Permission for Your Folder to Fix Error
You may not have full permission for your folder, which leads to a “The Directory Is Not Empty” error when you try to remove the folder. You can fix that by taking ownership of your chosen folder.
- Right-click your folder and choose Properties.
- Select the Security tab and choose Advanced.
- Select Change next to Owner.
- Type your Windows username in the text box, select Check Names, and choose OK.
- Select Apply followed by OK.
- Choose OK on the Properties window.
- Try to remove your folder.
Run a Full Virus Scan on Your Windows PC
Your Windows PC may have a virus or malware infection, and this item may have gained unauthorized control over your folder, preventing you from deleting your folder. In this case, you can run a full virus check and find and remove all the threats from your PC.
You can use a third-party antivirus program or Windows’ built-in Microsoft Defender Antivirus to scan your computer. Here are the steps for running a full scan using the latter.
- Open Start, find Windows Security, and launch the app.
- Select Virus & threat protection in the app.
- Choose Scan options on the following page.
- Select Full scan and choose Scan now.
- Wait for your antivirus to finish scanning your PC.
Fix Corrupt Windows Files
Windows’ operating system files may have become corrupt, causing your folder not to delete. In this case, you can use Windows’ built-in SFC (System File Checker) tool to find and fix all corrupt files on your computer.
This tool runs from a Command Prompt window and recognizes and replaces all the faulty system files on your storage.
- Open Start, find Command Prompt, and select Run as administrator.
- Choose Yes in the User Account Control prompt.
- Enter the following on the Command Prompt window and press Enter:
DISM.exe /Online /Cleanup-image /Restorehealth
- Then, use the following command to fix your corrupt files: sfc /scannow
- Try to remove the directory.
Restore Your Windows System
If Windows’ “The Directory Is Not Empty” error still doesn’t go away, roll back any recent changes you may have made to your PC. One way to do this is by using Windows’ built-in System Restore tool.
This tool allows you to roll back your system to a restore point created in the past, which helps fix many issues.
- Open Start, find Recovery, and select the item in the search results.
- Choose Open System Restore on the following page.
- Select Next on the tool’s first screen.
- Choose the most recent restore point on the list and select Next.
- Select Finish to begin restoring your PC.
Finally, You Can Delete Your Folder on Your Windows PC
It quickly gets frustrating when you want to delete a folder but can’t do that as Windows keeps displaying the “The Directory Is Not Empty” error. Luckily, this error isn’t too hard to deal with, and you can use the methods above to resolve the problem.
Once the item locking the folder is gone, you’ll be able to delete your folder without any issues.