Windows

Sync any folder in Windows to OneDrive

OneDrive is great piece of software but at the time of writing it misses some of the features that competitors (in particular Google Drive) like linking any folder to OneDrive. You can only synchronize data from OneDrive to your user folder (or wherever you define it). But you can't tell OneDrive to synchronize C:\Support, D:\MyFolder, C:\MySuperHiddenFolder.

Well at least not natively… unless you use the trick below.

Solution

The way to solve is by using neat feature called Symbolic LinksSymbolic links are basically advanced shortcuts. Create a symbolic link to an individual file or folder, and that link will appear to be the same as the file or folder to Windows—even though it’s just a link pointing at the file or folder. Since I wanted to synchronize C:\Support to OneDrive, all I had to do was…

Rename C:\Support to C:\Support-Old

Open CMD as Administrator and use mklink application that's brought to you by Microsoft as hidden gem

Run following command – where Targetfolder shouldn't exists (keep in mind REM below means it's a comment). So just one simple command is necessary 

REM mklink /J <TargetFolder> <OriginalFolder> 
mklink /J "C:\Support" "C:\Users\pklys\OneDrive - Evotec\Support"

Notice how the folder has special arrow next to it. It means it's Hard Linked now. 

Now anything you create in C:\Support (or folder of your choice for that matter) folder or on your OneDrive will get synchronized both ways (technically it's same file – no synchronization occurs). Isn't that great?

Gets hardlinked to OneDrive, and at same time synchronized by OneDrive to Cloud! 

And best of all it doesn't take double space on your drive. Enjoy!

PS. To get rid of a symbolic link, you can simply delete it like you would any other file or directory. Just be careful to delete the link itself rather than the file or directory it’s linking to. In my case this would be deleting C:\Support rather then the folder on OneDrive.

This post was last modified on February 16, 2018 13:42

Przemyslaw Klys

System Architect with over 14 years of experience in the IT field. Skilled, among others, in Active Directory, Microsoft Exchange and Office 365. Profoundly interested in PowerShell. Software geek.

Share
Published by
Przemyslaw Klys

Recent Posts

Upgrade Azure Active Directory Connect fails with unexpected error

Today, I made the decision to upgrade my test environment and update the version of…

2 months ago

Mastering Active Directory Hygiene: Automating Stale Computer Cleanup with CleanupMonster

Have you ever looked at your Active Directory and wondered, "Why do I still have…

3 months ago

Active Directory Replication Summary to your Email or Microsoft Teams

Active Directory replication is a critical process that ensures the consistent and up-to-date state of…

7 months ago

Syncing Global Address List (GAL) to personal contacts and between Office 365 tenants with PowerShell

Hey there! Today, I wanted to introduce you to one of the small but excellent…

12 months ago

Active Directory Health Check using Microsoft Entra Connect Health Service

Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…

1 year ago

Seamless HTML Report Creation: Harness the Power of Markdown with PSWriteHTML PowerShell Module

In today's digital age, the ability to create compelling and informative HTML reports and documents…

1 year ago