Home » How To » How to Sync Any Folder to OneDrive on Windows

How to Sync Any Folder to OneDrive on Windows

To sync a folder with OneDrive, all you have to do is create one in the OneDrive directory. For system folders like Documents, Desktop, Pictures, etc., OneDrive has options you can enable. However, what if you want to sync a folder outside the OneDrive directory?

With a simple trick, you can sync any folder with OneDrive on Windows. That way, you can sync your important files with the OneDrive cloud without copying or moving the folder to OneDrive. Once synced, you can access them anywhere you want as long as you have an internet connection.

In this quick and easy OneDrive guide, let me show you the trick to sync any folder on Windows with OneDrive.

Table of contents:

  1. How to sync any folder to OneDrive
  2. How did we do this (Symbolic links)?
  3. Few important things to keep in mind
  4. Conclusion

How to sync any folder to OneDrive

As I said, we need to create a Symbolic Link. To do that, we need to use the Command Prompt.

  1. Open the Start menu.
  2. Search for “Command Prompt.”
  3. Click on “Run as Administrator” to open cmd as admin.
  4. Run the below command while replacing dummy folder names.
    mklink /J "%UserProfile%\OneDrive\DestinationFolder" "D:\SourceFolder"
  5. You should see the “Junction created” message.
  6. If you want to sync other folders with OneDrive, execute the command as needed.
  7. With that, you’ve synced an outside folder with OneDrive.

Steps with more details:

First, open the start menu, search for “Command Prompt,” and click on the result to open the Command Prompt. If you are trying to sync a system folder, you should open cmd as admin.

open command prompt

Once the Command Prompt window opens, run 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 with a “-Junction” suffix. That way, you will know it’s a junction folder.

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.

sync any folder with onedrive
  1. You will see the “Junction Created” message as soon as you execute the command.
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.

outside folder synced with onedrive

Of course, when you open the junction folder, you will see all your files from the source folder.

synced folder contents

From this point forward, any modifications you make in the source folder will be instantly reflected in the junction folder and synced to OneDrive.

Since we don’t want to copy or move the target folder to the OneDrive folder to sync it with OneDrive, we will create a symbolic link with a directory junction. Doing this creates a kind of link between the source directory and the destination directory. With the junction link, any changes you made to the source folder will be reflected in the destination folder.

Though the junction directory looks like a regular folder for normal users, it is nothing but a shortcut that lets you access the source directly.

You can learn more about the Symbolic Links from this official Microsoft Docs page.

Few important things to keep in mind

When using symbolic links (symlink) to create junctions, you should keep a few things in mind.

First, remember that this is just a link/shortcut. You are not copying the files. Any changes you make in either of the folders will reflect in the other folder. For example, if you delete a file from the junction folder in OneDrive, that change is reflected in the source folder. i.e., the file will be deleted from the source folder. That same is true vice-versa.

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, back up the source folder and then delete the junction directory.

Syncing any folder to OneDrive — Conclusion

As you can see, though not a straightforward process, with this simple trick, you can sync any folder in your system with OneDrive without moving the folder or file to the OneDrive folder. As useful as this trick is, it is important to remember the limitations that come with symlinks.

That is all. I hope this simple OneDrive how-to guide helped you.

If you are stuck or need help, send an email, and I will try to help as much as possible.

If you like this article, check out how to delay OneDrive startup and how to stop OneDrive Sync on Windows 11/10.

4 thoughts on “How to Sync Any Folder to OneDrive on Windows”

  1. Avatar for Gavriil

    thanks for the post.
    allmost perfect.

    From the junction folder if i delete a pdf it syncs with the original outside onedrive folder, but it doesnt sync on cloud.

    and it doesnt add newer docs i place on either folder (junction or physical)

  2. Avatar for Jamie

    Apparently this only works with local directory folders. I was trying to do this with a mapped server drive and the script would not allow it.

  3. Avatar for Jason

    Just ridiculous. If folders can be synced outside of Onedrive folder then why don’t Microsoft implement this in Onedrive? It’s no problem for Google Drive.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top