I did research beforehand on google How to Sync Any Folder to the Cloud With Symbolic Links and on Ask Different, but I still cannot find an answer to this specific question.

The file I want to symlink to is in the following format: /Users/Name/OneDrive\ -\ X\ Y\ Education/Documents/Z\ Documents

Z\ Documents is the name of a subfolder of (~/Documents)

I tried rewriting it in different ways for it to be without any spaces as symlink requires there to be like that, but had no luck. I am quite inexperienced in this, but I was thinking maybe you can do something like quotation marks for Terminal to consider it one 'term'?

If something in this question is unclear, please leave a comment and I will do my best to clarify. Any possible answers are appreciated. Thank you.


Thank you for your help and effort. I made a mistake in my question with the directories, but I think it is a bit too big to correct, so I am going to rewrite it here if it's alright.

Here the directory that I want to link to:

/Users/NAME/OneDrive\ -\ PATH\ TO\ TARGET/Documents/X\ Documents

The first part is the location of the folder on my drive. The second part (after the first space) where is states 'PATH TO TARGET" is some part of the directory which is required to connect to the server or something like that. 'Documents' is a subfolder of OneDrive and 'X\ Documents' is a subfolder of 'Documents'.

I have listed the 'source' ONLY above. The target I would like to be found in folder in my defaults downloads location:

~/Downloads/X Documents

What I would like to happen, is when I open the folder X Documents, I am redirected to the source directory I described earlier (X Documents within Documents within OneDrive)

Thank you again for your time helping me out with this.

  • Why do you have "\ PATH\ TO\ TARGET" in your question? What's the actual directory you are trying to create a symlink for?
    – Allan
    Nov 3, 2016 at 19:10
  • \ PATH\ TO\ TARGET = \ X\ Y \ Organization OneDrive for business, I don't want to publicly state the name of the organization.
    – Tes
    Nov 3, 2016 at 22:50

1 Answer 1


To get a file symlinked from your Documents folder to your OneDrive folder (or any folder for that matter) you need to format the command completely and properly

Creating a symlink:


More specifically, it must take on the form

ln -s /path/to/source /path/to/target

Let's say we are trying to create a link from a folder called "Personal" that's located on OneDrive and you want it to show up under Documents.

ln -s /Users/USERNAME/OneDrive/Personal /Users/USERNAME/Documents/Personal

Now, in your "Documents" folder, you will see a folder called "Personal."

Spaces in the path and/or filename

There are two ways to address spaces within the path or filename. Using the example from above, if the folder was called Personal Stuff we could handle it one of two ways:

  • Use backslashes () to escape the space:

    ln -s /Users/USERNAME/OneDrive/Personal\ Stuff /Users/USERNAME/Documents/Personal\ Stuff

  • Use quotes (") to encapsulate the whole string:

    ln -s "/Users/USERNAME/OneDrive/Personal Stuff" "Users/USERNAME/OneDrive/Personal Stuff"

Using the tilde (~) for your home directory

The tilde (~) is just a shortcut to your home directory. So, instead of typing out /Users/USERNAME/foo/bar/filename.ext you can simply shorten it to ~/foo/bar/filename.ext

You can use it when creating your symlinks with no problem: ln -s "/Users/USERNAME/OneDrive/Personal Stuff" "~/OneDrive/Personal Stuff"

Keep in mind that the tilde (~) changes for each user. This is why I have gotten in the habbit of just typing out the whole path; just to be sure I'm putting the link exactly where I want it.

Symlinking per your example

ln -s ~/OneDrive\ -\ Documents/X\ Documents ~/Downlaods/X\ Documents

This will create a link called "X Documents" in the Downloads Folder of the "X Documents" folder found on OneDrive.

You can find further details about the the ln command by typing man ln.

  • This is really cool. I have Office-oneline365 with 1drive and I was wondering how I could sync my documents. I am going to try this today.
    – Buck Naked
    Nov 3, 2016 at 15:31
  • Added an edit which changes your 'Symlink per your example'. Would really appreciate some help with that. Thank you.
    – Tes
    Nov 3, 2016 at 18:53
  • The symlinks end up being considered scripts by OneDrive and nothing gets copied except the small script Apr 4 at 1:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .