Renaming OneDrive Folder Name

January 5, 2018
reference onedrive

Renaming the OneDrive folder name. Take control!

Update 1/7/2018:

If your business name contains symbols then Nuget may not properly be able to restore packages. I am not 100% certain this is what it is. But moving a project out of the really long name (that contains an &) and into a simple c:\projects directory allowed for the project to restore and build.

That sucks.


You can't. Sorry. I know that was sort of link bait. I apologize.

But, there is a solution. First the issue - to ensure we're not talking apples to grapples.

When you add a "business" OneDrive account to your PC (different than your "personal" OneDrive account) It will be named (as of this writing) {whatever location you select}\OneDrive - {TenantName}. Which means, if your tenant name (or your company name which is the case for most people) is The Best Company Ever & Other Services, LLC and you go with the default user root folder, your OneDrive folder will be:

C:\Users\tony\One Drive - The Best Company Ever & Other Services, LLC

I am not even joking. How Microsoft - not only a software company, but an OS building company, decided to not only allow but force a directory name that can be more than 50 characters long (70 in my example) which can easily run into the "sorry, kid, file name too long" error is beyond me. Seriously. Every sync solution known to humans and canines (and felines) allows you to select an arbritrary folder to sync to. This amazes me. What was the dev and PM and code reviewer and colleages and peers thinking?

Dev: I went ahead and hard coded the directory with "ONE DRIVE - " and concatenated the tenant name to make sure we're using a good name.

PM: Awesome. Good thinking.

Intern (now at Dropbox): Can there be a conflict with length names or tenant names that conflict?

Dev/PM: <sarcasm>Really?</sarcasm> No. Merge.

Maybe it didn't go quite like that...Anyway, assuming that that's why you're here - my solution is rather simple. And much easier than some of the regedit based solutions or renaming your tenant in O365. Use softlinks or symlinks or symbol links. Basically, trick your computer into thinking that a directory is a more than it is.

You point whatever directory you want to use to the actual directory. So, using PowerShell because CMD is being deprecated (I guess) and hidden from my various shortcuts...

New-Item -Path {the fake location} -ItemType SymbolicLink -Value "{the real location}"

which translates to:

New-Item -Path C:\Projects -ItemType SymbolicLink -Value "C:\Users\tony\OneDrive - The Best Company Ever & Other Services, LLC\Projects"

If you are using the black box referred to as the command prompt:

mklink /D C:\Projects C:\really-long-title-i-dont-want-to-copy-and-paste-anymore

And, as far as I can tell so far, works as expected. Yay Unix!