Directory links – why might you want to use them?

Let’s say that you’ve got a folder containing important files and they’re located in a location that your cloud storage application can’t access (OneDrive for Business, I’m looking at you with your ‘must be in a known folder’ malarkey) but you want them to be replicated to your cloud location; how would you go about doing this?

In the *ux world, you’d use something like ln -s, so what’s the Windows equivalent?

mklink /j is your friend….

So, let’s look at this with an example. You’ve got some scripts stored in C:\Scripts , you’re using OneDrive for Business and you want those scripts to be backed up to OD4B.

OD4B can’t actually access anything outside of its predefined locations, so what you need to do is move the folder Scripts into your OneDrive folder instead and link back to them. In real terms, C:\Users\YourUsernameHere\OneDrive – Your Organization\Scripts becomes the actual location of your scripts and C:\Scripts is merely a link.

Next, you need to create a link to where they are now. Drop to the command prompt and run

mklink /j c:\Scripts "c:\Users\YourUsernameHere\OneDrive - YourOrganization\Scripts"

Note the double quotation marks around the actual location due to the spaces in the structure. The important thing here is the /j – without this switch, mklink effectively creates a native Windows shortcut which will redirect you to the location inside your OD4B folder instead of the original location that you actually want to be in. This might work for you, but if you’ve got anything hardcoded to look in C:\Scripts, that thing will likely break without the /j switch.

With over 20 years of working in the IT industry, I have a wide experience of many different areas of Information Technology and have specific interests in Cloud Solutions, Windows, Active Directory, and Infrastructure. I'm by no means a coder or programmer, and any snippets I post here work fine in my environment, but I give no assurances to how they may work for you.