2

I have two usb flash drives D:\ and H:\, inside they have some bin files

001.bin,002.bin on D

003.bin 004.bin on H

I want to create a symbolic link in such a way that when a program accesses C:\bins it will find inside all files 001.bin,002.bin,003.bin,004.bin from the usb drives, and access them from the usb drives.

How can I do this?

6
  • You want to individually link each file?
    – Bob
    May 28, 2012 at 14:06
  • @Bob I'm not planning to remove the drives in this case so I'm fine with that, and yes I would like to individually link each file. How can I do that?
    – Panayiotis
    May 28, 2012 at 14:07
  • Sorry about that, I was thinking of junction points. I've never tried symbolic links cross drive with removable media.
    – Bob
    May 28, 2012 at 14:09
  • Ok, just tried it. Changing the drive letter does break the link, so beware of that.
    – Bob
    May 28, 2012 at 14:12
  • 3
    @Bob: It should be possible to avoid this by creating symlinks using the volume GUID instead of drive letter, as in \\?\Volume{1234-56-...}\001.bin. (This is what mountpoints and junctions use by default.) May 28, 2012 at 14:17

2 Answers 2

4

It is impossible to merge two directories using a single symlink, since a link can only have one target. This applies equally to junctions and symbolic links. (On Linux this could be achieved at VFS layer, by using virtual filesystems such as overlayfs or unionfs; some other Unix-like systems also have similar concepts of "union mounts". No such thing on Windows, unfortunately.)

But if the .bin file names always stay the same, you can create symlinks to the files directly:

mkdir c:\bins
mklink /f c:\bins\001.bin d:\001.bin
mklink /f c:\bins\002.bin d:\002.bin
mklink /f c:\bins\003.bin h:\003.bin
mklink /f c:\bins\004.bin h:\004.bin
...and so on

This could be rewritten as:

for /f %f in (d:\*.bin) do mklink /f "c:\bins\%~nxf" "%~f"
for /f %f in (h:\*.bin) do mklink /f "c:\bins\%~nxf" "%~f"
0
1

I don't think that you will be able to get the files from D: and H: to appear as siblings within C:\bins. You should be able to use the following commands to build two directory junctions below C:\bins.

>mklink /D /J "C:\bins\d" "D:\"
>mklink /D /J "C:\bins\h" "H:\"

This will give you c:\bins\d and c:\bins\h where you will find 001.bin,002.bin in c:\bins\d and 003.bin, 004.bin in c:\bins\h.

You must log in to answer this question.

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