How to rename or remove spaces from OneDrive folder name

I have two OneDrive accounts, one for personal, one for work. When you have two accounts on the same machine, OneDrive automatically creates a folder for the second account in this format OneDrive - {Name}. Which causes endless issues as a dev, such as running tox or long file name issues.

My first attempt at this took me down the path of editing the registry, basically I found all occurrences of OneDrive - Microsoft and replaced it with OneDriveMS - but that’s a lot of work to do on every machine and error prone.

I googled my way to a better solution, and giving credit, I found a good solution here: I’m blogging it because I’m hoping the SEO of this page helps you out. So, while this post is titled “rename or remove spaces” we aren’t going to actually do that - I just gave it that title so you could easily find it.

All you have to do is create a junction link from the name you want to the name of the OneDrive folder via the following mklink command. You can learn more about mklink here: I personally love this solution because I don’t have to mess with the registry and OneDrive just works as is.

Here’s the generic command:
mklink /J desired_name "OneDrive - company

Here’s what I used:
mklink /J OneDriveMS "OneDrive - Microsoft"

  1. Open command prompt as administrator
  2. Navigate to the parent folder of your current OneDrive folder, mine was c:\Users\JonGallant\
  3. Execute the above mklink command.

Here are the folders before I executed it:

Here are the folders after, you now see OneDriveMS

When you access the folder, you see the new folder name, not a redirection.

From now on, just open all your files from the junction folder, not the OneDrive folder.

Granted, I’ve only just figured this out and might have issues. I will update this post if I do. Seems to be working out so far.