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.
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.
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.
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:
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 script.
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 cleaner than my python solution!
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
*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
Was able to fix the error and run the powershell command without error.
This was verified by Samer who first encountered this issue.