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. Good job Microsoft! Just another reason for me to stay the hell away from you. 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 went ahead and 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 this time.

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:

import os

l = []
for root, directories, filenames in os.walk('E:\Personal'):
    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)

 

What other thing I learned in this ordeal? As soon as I’m used to living without Adobe, good bye Microsoft and your bullshit!

One thought 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

Leave a Reply

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