Cannot Remove Folder, Directory is not empty. (SOLVED)
The error message "Cannot delete folder, directory is not empty" can be faced on any Windows based computer (Windows 10, 8, 7, Vista or XP) if you try to delete a folder that the system cannot access due to the permissions applied to it.In other cases the "Cannot Remove folder because the directory is not empty" issue, can be solved after scanning the hard disk for errors by using the "CHKDSK" command.
In this tutorial you will find detailed instructions on how to resolve the following errors while deleting a file or folder on Windows 10, 8, 7, Vista or XP:
-
- "Cannot remove Folder or File. The Directory is not Empty"
- "Folder Access Denied. You need permission to perform this action"
- "Cannot delete file. Cannot read from the source file or disk"
- "Cannot Remove Folder. Cannot find the specified file"
- Cannot Delete a File or Folder error in Windows.
How to fix: Cannot Remove Folder or File. The Directory is Not Empty or Access is Denied
Method 1. Run CHKDSK on the drive.
The first step to resolve the ?Cannot remove folder" or "Cannot remove file" issue(s), is to perform a check disk scan on the disk, that contains the folder that we cannot delete.
1. Open an elevated command prompt (Command Prompt (Admin)).
2. In the command prompt window, type the following command and press Enter: *
- chkdsk c: /R
* Press the “Y” key if asked to check your disk the next time your system restarts.
3. After disk checking try to delete the problematic folder (or file). If you still cannot remove the folder, proceed to method-2.
Method 2. Modify Folder's (or File's) Permissions.
1. In Windows explorer, right click at the folder that you cannot delete and select Properties.
2. Select the Security tab and then click Advanced.
3. Click Change Owner
4. In the object name box type, type the name of the Administrator account (e.g. "User1" in this example) and then click OK.
5. Check the "Replace Owner on subcontainers and objects" checkbox and then click OK & OK again to close the security settings.
6. Now try to delete the folder (or the file) that you cannot delete. If you receive the same message, then proceed to method-3 below.
Method 3. Delete File or Folder from Command Prompt.
1. Open an elevated command prompt (Command Prompt (Admin)).
2. In elevated command prompt, give the below commands, according your case:
A. To delete a folder: *
- takeown /F "FolderName" /r /d y
- icacls "FolderName" /grant Username:F /t
- rd "FolderName" /S /Q
* Notes:
1. Replace the "FolderName" with the full path and the name of the folder that you cannot delete.
2. Replace the "Username" with the username of the Administrator account.e.g: if you want to delete the "Demo" folder (and its subfolders and files) under the "C:\Program Files\" directory and your Administrator account name is "User1", then the commands should be:
- takeown /F "C:\Program Files\Demo" /r /d y
- icacls "C:\Program Files\Demo" /grant User1:F /t
- rd "C:\Program Files\Demo" /S /Q
B. To delete a file: *
-
- takeown /F "Filename"
- icacls "Filename" /grant Username:F
- del "Filename"
* Notes:
1. Replace the "Filename" with the full path and the name of the file that you cannot delete.
2. Replace the "Username" with the username of the Administrator accounte.g. if you want to delete the "Example.doc" file under the "C:\Temp" directory and your Admin account name is User1, then the commands should be:
-
- takeown /F "C:\Temp\Example.doc"
- icacls "C:\Temp\Example.doc" /grant User1:F
- del "C:\Temp\Example.doc"
Method 4. Delete folder with 7zip.
1. Download and install 7zip file archiver.
2. After installation, go to installed programs and open the 7-zip File Manager.
3. In 7zip file manager, click the Plus (+) symbol in the menu.
4. From the drop-down menu, select the drive that contains the folder/file you cannot delete.
5. Then navigate to the folder/file that you cannot delete and select it.
6. Finally, hold down the SHIFT key and click the Delete button to remove the folder.
That’s all folks! Did it work for you? And if so, by what method?
Please leave a comment in the comment section below or even better: like and share this blog post in the social networks to help spread the word about this solution.
- FIX: SC OpenService FAILED 5: Access is denied (Solved) - May 2, 2024
- (Solved) Service ESET (ekrn) could not be deleted. - April 30, 2024
- How to Block Windows 11 Upgrade on Windows 10. - April 25, 2024
Renaat Moerman
March 14, 2019 @ 11:08 am
Super instructions. I had a Sync folder stuck. I could remove it with the elevated command line instructions.
Kayode
May 17, 2019 @ 4:51 pm
Thanks a lot. It deleted after chkdsk finished it's own work
Jurom
June 6, 2019 @ 3:07 am
Method 3 works best! Thank you.
Akshay
June 20, 2019 @ 9:51 am
I had tried every solution for this problem before i came across method 3, and finally it worked for me. Thank you so much!!!
Zameel
June 30, 2019 @ 9:36 pm
There is a very easy method, if you have installed winrar:
Follow the steps:
1. Add to archive…
2. Select Archive method as ZIP
3. In Archiving options tick: Delete files after archiving and OK
Now the folder should be deleted and later you can delete the archive one.
Ian
November 23, 2019 @ 7:12 pm
I tried all of the above suggestions, but only Zameel's winrar option worked for me:
I first manually deleted everything from the recycling bin that Windows 10 could see, so I could work out where the problem was.
Windows showed the recycling bin as empty.
Dos could see a file hierarchy, but it showed the 2 bottom folders as empty, even though it said they weren't empty when I tried to use RD to delete the folders.
Winrar could see the files in those folders, but the 'delete' option on the winrar ribbon failed.
I then followed Zameel's instructions and the files were deleted from the folders.
I then used Dos and Winrar to delete the folders (I deleted one folder via each to check both methods worked)
Many thanks, Zameel – I can now empty the recycling bin via the normal right-click method!
PS It shouldn't make any difference, but for info, I have 3 hard drives on my PC (C, D and J) and the corruption was in the recycling bin on the D drive.
Sir Junior
April 25, 2020 @ 7:48 pm
This worked for me, but with 7zip!!!
I tried everything else. CHCKDSK, multiple command prompt instructions, the ownership stuff, renaming, placing inside of another file. NOTHING!
This seems so simple but it worked. THANK YOU SO MUCH!
Patrick Jay
July 10, 2023 @ 4:04 pm
I've tried almost every method found and the only one that worked is using zameel's method. but I used 7zip instead of winrar. If you are one of those experiencing the undeletable folder or file issue, don't take the method of using winrar or 7zip as a joke, it's more powerful than cmd or powershell with admin right (I tried both, both didn't work) so give it a try. It's easier and safer than using cmd or powershell and it works.
Ahazuerus
December 25, 2019 @ 3:56 pm
The third method was a great success , thanks !!
wilson N J
August 21, 2020 @ 10:01 am
Awesome..It worked for me.
ozzy
May 2, 2022 @ 8:17 pm
if are you not solve problem already please use this way.
please disable bitlocker if is activated already
disable secure boot in bios if its enabled already
download live linux and install it usb with rufus (https://releases.ubuntu.com/22.04/ubuntu-22.04-desktop-amd64.iso)
boot with usb,
it will ask you try or install ubuntu (SELECT TRY)
after desktop you will see your HDD left side on screen
and simply delete files.
not: if your hdd is not AHCI mode. linux will not see disks please set it AHCI mode in bios.
after delete file. set it to back SATA mode…. because won't boot
Richard Black
June 1, 2022 @ 4:31 pm
I follow this web content . I use LongPathTool. That's amazing.
Tina C.
January 4, 2023 @ 5:46 pm
I tried this but I'm running into an issue in which my OneDrive is my desktop in Windows 10. There are folders here that apparently got corrupted and I can't find any online method that allows me to delete them.
The error is: "The tag present in the reparse point buffer is invalid."
I've done a Google search on this phrase and have tried all the options and suggestions, and none of them have worked. Help!
Lakonst2013
January 5, 2023 @ 2:55 pm
Try the following:
1. Pause OneDrive sync.
2. Go to OneDrive online and delete the folders from there if you don't want them. Otherwise download them to another location on your disk and then delete them from OneDrive online.
3. Restart the PC in Safe Mode and Delete the folders from the local disk.
4. Restart your PC normally.