With a simple trick, you can sync a folder that is not in OneDrive folder with OneDrive in Windows. Let me show you.
OneDrive is one of the most widely used cloud storage services and is built into Windows 10. To sync a file or folder with OneDrive cloud, all you have to do is create, move or copy the contents into the OneDrive folder. This lets you sync your important files so that you can access them anywhere you want as long as you have an internet connection.
However, if you want to sync a folder that is outside the OneDrive folder without moving or copying it, then you need to do some magic. So, without further ado, let me show you how to sync any folder, no matter its location, with OneDrive.
How Do We Do This?
Since we don't want to copy or move the target folder to the OneDrive folder, we are going to create a symbolic link with directory junction. When you do this, it creates a kind of link between the source directory and the destination directory. Though the junction directory looks like a regular folder for normal users, it is nothing but a kind of shortcut that lets you access the source directly.
You can learn more about the Symbolic Links from this official Microsoft Docs page.
Now, I know all this sounds complicated. However, in practice it is really easy. Just follow the below steps and you will be good to go.
Steps to Sync Folder Outside OneDrive Without Moving or Copying
As I said, we need to create a Symbolic Link. To do that we need to use the Command Prompt.
1. First, open the start menu, search for "Command Prompt" and click on the result to open the Command Prompt.
2. In the Command Prompt, execute the below command while replacing the dummy paths with the actual paths.
mklink /J "%UserProfile%\OneDrive\DestinationFolder" "D:\SourceFolder"
Here, the first path is where you'd like to create the new directory junction. In our case, that is in the OneDrive folder. You can name the folder anything you want by replacing "DestinationFolder". Generally, it is helpful to name the folder the same as the source.
The second path is the source folder path. i.e, the folder you'd like to sync with OneDrive.
Note: If you've moved the OneDrive folder from its default location, you need to modify the first path in the command to reflect that change.
3. As soon as you execute the command, you will see the "Junction Created" message.
That is it. If you open the OneDrive folder, you will see a new folder with the name you chose in the command. To differentiate the junction directory from the other folders, you will see a little arrow overlay icon which suggests that it is just a shortcut and not a real folder.
Of course, when you open the junction folder, you will see all your files from the source folder.
From this point forward, any modifications you make in the source folder will be instantly reflected in the junction folder and are synced to OneDrive.
Things To Keep In Mind
Any changes you make in either of the folders will reflect in the other folder. Remember, this is just a link/shortcut. You are not copying the files.
Since the junction directory is just a link, you cannot use the Files on Demand feature on this specific folder. Other regular folders and files are not affected, though.
If you ever want to remove the link, simply delete the junction directory inside the OneDrive folder. This action will not delete the source folder. If you are unsure, backup the source folder and then delete the junction directory.
That is all.
Hope that helps. If you are stuck or need some help, comment below and I will try to help as much as possible.