Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
You want to individually link each file? –  Bob May 28 '12 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 '12 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 '12 at 14:09
    
Ok, just tried it. Changing the drive letter does break the link, so beware of that. –  Bob May 28 '12 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.) –  grawity May 28 '12 at 14:17

2 Answers 2

up vote 4 down vote accepted

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"
share|improve this answer
    
That was what I was looking for, thanks! –  Panayiotis May 28 '12 at 14:18

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.