How do I delete folder that that was synced with Onedrive but refused to stop syncing?

Viewed 4541

There is this project folder that I am trying to delete but it keeps denying me even after I ran rm -force. It shows me this instead:

is an NTFS junction point. Use the Force parameter to delete or modify this object.
At line:1 char:1
+ rm .\db\
+ ~~~~~~~~
    + CategoryInfo          : WriteError: (C:\Users\KenGon...git\objects\db\:DirectoryInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : DirectoryNotEmpty,Microsoft.PowerShell.Commands.RemoveItemCommand

.

rm : There is a mismatch between the tag specified in the request and the tag present in the reparse point
At line:1 char:1
+ rm .\db\ -force
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Remove-Item], Win32Exception
    + FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.RemoveItemCommand

When is move into the folder, and tried to list the folder contents, it shows me this instead:

ls : The tag present in the reparse point buffer is invalid.
At line:1 char:1
+ ls
+ ~~
    + CategoryInfo          : ReadError: (C:\Users\KenGon....git\objects\db:String) [Get-ChildItem], IOException
    + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand

Is there any way in which I can delete this folder? I have already stopped syncing with OneDrive and restarted it multiple times. The advice I found on Microsoft's forums does not seem to help. Even after pausing the sync, the folders still show a blue circular arrows - still syncing?

2 Answers

It is dumb, but I ran chkdsk /f /r and had to hard force reboot my computer. Not sure what the exact error was that caused the folder to be immutable. Seems to be some corrupted data when I tried to remove OneDrive while it was syncing, causing some problems.

Alternative and potentially faster solution: Use Windows Subsystem for Linux (WSL), change to directory and delete files/folders

rm -r -f mybrokenfolder
Related