Windows 8.1 - mklink to a folder with files in it

0

I have a directory 'dir1' with some files in it and a directory 'dir2' where I'll add some files. How can I create a link/junction (or just connect them)? I tried "mklink /D (or /J) dir1 dir2" but apparently it's not working and if it would I think that dir1 would just be dir2. I want dir1 to have the files it has now and when I add files to dir2 to show up in dir1.

JohnGRThess

Posted 2016-07-05T16:48:34.687

Reputation: 41

Answers

0

I tried mklink /D (or /J) dir1 dir2

I have a directory 'dir1' with some files in it and a directory 'dir2' where I'll add some files.

You have the directories the wrong way around. You also need to remove dir2 before creating the link.

The syntax for mklink is:

MKLINK [[/D] | [/H] | [/J]] Link Target

Note:

  • mklink creates the link so dir2 should not exist before you run the command.

In your case dir2 will be the new link and dir1 will be the target, so you need to use:

rd dir2

Followed by:

mklink /d dir2 dir1

Or:

mklink /j dir2 dir1

Now dir2 has the files of dir1 (In other words dir2 is dir1). I don't want that.

That's what directory links are designed to do.

You need to rethink.

One option is to add the files to dir2 and then when in dir1 create symbolic link to the files in dir2. You can do this with:

cd dir1
mklink file \full\path\to\dir2\file

You have to do this for every new file added to dir2.


Further Reading

DavidPostill

Posted 2016-07-05T16:48:34.687

Reputation: 118 938

Yeah but now dir2 has the files of dir1 (In other words dir2 is dir1). I don't want that – JohnGRThess – 2016-07-05T17:16:45.507

@JohnGRThess That's what directory links are designed to do. You need to rethink. One option is to add the files to dir2 and then when in dir1 create links to the files in dir2. You can do this with mklink file \full\path\to\dir2\file. You have to do this for every new file added to dir2. Answer updated. – DavidPostill – 2016-07-05T19:39:52.700