Windows 10 delete reparse points in (sub)directories

Windows 10 delete reparse points in (sub)directories

Recently Windows 10 went through the fall creator’s update without my permission, I found out that I can no longer access my onedrive folder while I’m booted into linux. To clarify, the folder does not shows up in gui but does shows up red when using ls command in the directory. Through many frustrations and this post here, I realize it’s something the update did that created reparse points on everything in my onedrive folder. And from the same place I found the command below to delete reparse points, one at a time. It wasn’t enough to solve the problem since I have more than 100 folders in my onedrive.

fsutil reparsepoint delete "C:\Path\To\OneDrive\Folder"

Since it only happened to my folders/files in onedrive, first thing I tried is move everything out of it to a separate location and create symlink back in onedrive so I can keep them updated in the cloud. Unfortunately, that did not fix the problem, those reparse point lives and still denying me access to my own files. Frustrated, I started using fsutil command to delete the reparse points one by one. Soon I realized it wasn’t an acceptable solution since it’ll take hours. So frustrated and angry at Microsoft, I created a python script to apply the command above to everything in the directory.

First through I need to get a list of all the files/directory/subdirectory. I found this really neat one line command in stackoverflow post here.

[val for sublist in [[os.path.join(i[0], j) for j in i[2]] for i in os.walk('./')] for val in sublist]

Do note that you need to replace ‘./’ to whatever path string you desires.

However, this one line command only gather a list of files, without directory or subdirectories.

With help from this post, it is this command here that really does the job of gathering everything.

l = []
for root, directories, filenames in os.walk('./'):
    for directory in directories:
        l.append(os.path.join(root, directory))
    for filename in filenames:
        l.append(os.path.join(root, filename))

Now that I have a list of all the files, directories and subdirectories, I can use a for loop to run the fsutil command on each and every one of them. Since my computer is fast enough and I’m lazy, I’m not going to shy away from launching too many command prompt and included a line to start command prompt so that I can verify it works.

Here’s the final script I whipped up to solve the problem, it will launch a cmd window for every single thing in the selected folder, so anyone who found and intend to use it beware of its danger:

import os

l = []
for root, directories, filenames in os.walk('E:\Onedrive'):
    for directory in directories:
        l.append(os.path.join(root, directory))
    for filename in filenames:
        l.append(os.path.join(root, filename))

for a in l:
    args = 'fsutil reparsepoint delete "' + a + '"'
    start = "start cmd /k " + '"' + args + '"'
    os.popen(start)

Update 31/08/2018:


Got replies below pointed out my mistake of including the start line at the end to run the command with cmd. The idea behind it was to running the command in a terminal so that I can verify that it works, but it was clearly unwise to include it in a for loop which would summons a cmd for every single file/folder you have, potentially crashing the computer. Taking that out and run os.popen(args) instead would be cleaner. Here’s the modified for loop.

for a in l:
    args = 'fsutil reparsepoint delete "' + a + '"'
    os.popen(args)

Update 05/02/2019:

Another very helpful reply! I should’ve mentioned that the cause to the reparse points are the “Files on Demand” feature in OneDrive. Turning it off should no longer create reparse points on your new files and folder. Unfortunately, Windows does not delete the already exist reparse points. According to empty_other’s reply below, launch powershell, navigate to OneDrive folder and run the command below should fix the problem. Much more cleaner than my python solution!

Get-ChildItem -Recurse -Attributes Reparsepoint | % { $n = $_.FullName.Trim(“\”); fsutil reparsepoint delete “$n” }

Update 13/03/2019:

While working on other codes I realize I can call windows command in the python window through subprocess. Running that in the python for loop would allow user to see the return of the command in the same python window, instead of opening a hundreds cmd windows to see it. Below is the updated code

import os
from subprocess import call

#gather a list of files/directories/subdirectories
list = []
for root, directories, filenames in os.walk('E:\Onedrive'):
    for directory in directories:
        list.append(os.path.join(root, directory))
    for filename in filenames:
        list.append(os.path.join(root, filename))

#run 'fsutil reparsepoint delete #filename' for every thing in the list
for file in list:
    call(["fsutil", "reparsepoint", "delete", file])

*Note that I have not tested this since I no longer have the issue. Do comment below if it doesn’t work.


Update 22/03/2019

Please note that there are users encountered the following error while using the powershell command posted on 05/02/2019 Update:

Error: The tag present in the reparse point buffer is invalid.

A comment by Stuart pointed out that running

chkdsk /r /f

Was able to fix the error and run the powershell command without error.
This was verified by Samer who first encountered this issue.

13 thoughts on “Windows 10 delete reparse points in (sub)directories

  1. thanks for the inspiration!
    but: delete the entire start line, call os.popen(args)
    there’s no need to start thousands of cmds and kill the system

    1. You’re right there’s no need for the start line, I did not think of that while I was writing this up. Thanks for letting me know!

  2. Had the same issue recently, with the result that I couldn’t delete my OneDrive folders. Seems Windows can’t delete reparse point folders.

    Turn off “FIles on Demand” option should prevent new folders and files from being created as reparse points. To fix the old files use powershell to navigate to your OneDrive folder, then run this:

    Get-ChildItem -Recurse -Attributes Reparsepoint | % { $n = $_.FullName.Trim(“\”); fsutil reparsepoint delete “$n” }

    Does the same thing as your Python script, I believe. But doesn’t spawn all those cmds.

    1. Yeap forgot to mention in this post, discovered “Files on Demand” is the cause and I’ve had it disabled ever since. Brilliant! I’ll add your solution to the post as well, hope I was smart enough to figure that out when I had the issue. Spawning the cmds weren’t necessary and it was a method for me to verify that it works while I was testing the script, I left it in while I execute it on all the files/folders, which was certainly unwise.

  3. Trying the last command in my one drive folder

    Get-ChildItem -Recurse -Attributes Reparsepoint | % { $n = $_.FullName.Trim(“\”); fsutil reparsepoint delete “$n” }

    I get the error:

    Error: The tag present in the reparse point buffer is invalid.

    1. Sorry no idea about this, I am not familiar with the powershell commands. Did you try what empty_other suggested and see which paths were giving the error?

  4. I’ve just experienced the same issue with ‘the tag present in the reparse point buffer is invalid’ – after a lot of frustration I actually solved my issues by running a disk check and repair. Once that had completed the folder I had issues with deleted successfully,

    I had tried the powershell command which still returned the error.

    Hopefully this will help anyone else having this issue.

      1. That is good to know and weird at the same time ;/
        Thanks Stuart for providing the solution! I’ll add it to the post as a potential solution.

    1. Script didn’t work for me either, but chkdsk /r/f did the job – man that took a lot of digging! – Thank you very much for sharing that.

    2. Did a fresh installation of Windows and as expected recreated the reparse point situation. To my surprise however the powershell command
      `Get-ChildItem -Recurse -Attributes Reparsepoint | % { $n = $_.FullName.Trim(“\”); fsutil reparsepoint delete “$n” }`
      Did not give me any error and did the job nicely.

      So still unsure what’s the issue here…

Leave a Reply

Your email address will not be published. Required fields are marked *