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.

Is there a way to create hardlinks to create a duplicate of a folder on the SAME drive (NTFS formatted)? I am looking to do something like this: XCOPY E:\TEMP\SAMPLE1* E:\TEMP\SAMPLE2\ /s but INSTEAD of actually copying the files and using up the extra drive space, just create hardlinks to the files.

Goal: there are only a handful of files that we do not need in the SAMPLE2 folder but want to keep all of them in SAMPLE1. The folder SAMPLE2 will eventually be copied off to another drive.

NOTE: the total content of SAMPLE1 is about 400GB (with multiple sub-folders contained therein) and each of the files that we are going to exclude from SAMPLE2 is about 20-40MB each (there are lots, 100+ files, located in various sub-folders).

So is there a way to do the equivalent of XCOPY (command above) except use hardlinks, and then we go and remove all the files we don't want in SAMPLE2 before copying them off to the external drive; then deleting SAMPLE2 folder.

share|improve this question

2 Answers 2

This is simple in theory. You need to create a symbolic link of the directory(s) which will do EXACTLY what you want. It copies shortcuts that look and act like real files to the user and programs. Then, you can delete the symbolic links you do not want which only deletes the links; then you copy the rest of the "files" (really links) like normal and it will copy the actual files.

But windows is GUI based, and there is no built in GUI solution to make symbolic links. Also, the command prompt made it difficult as well. (If your using Linux, its easy and straight forward via the terminal, and some graphical file managers like GNOME Commander makes it easy through the GUI as well.)

Sooo.. to execute the above solution the "easy" way is to download a plugin and support file (if needed; read download notes) here This will add symbolic link options to your right click menu. The ones you want are "Pick Link Source" to 'copy' the directory, then "Drop As > Hardlink Clone" to paste. Work in the linked directory as you want deleting files (links) and such. Then regular copy and paste it (NOT pick link and drop as) to where ever you want and Voila, shortcuts copied as files!

Finally, delete the linked folder and it's like nothing happened.

The plugin seems to work great. Try it out! Just be careful to make Hard Links ONLY (No soft links or junctions) and be sure to work with the links and not the real files!

Now for those who would mention mklink, here is what I ran into while developing this answer. Using mklink via the command prompt running as an administrator (search for CMD and right click and run as administrator) SHOULD work the same... But it didn't for me (and MANY others if you search). I got an access denied even after modifying privileges via secpol.msc. It seems to be a prevalent problem.

share|improve this answer
    
I need a solution that actually creates the folders and hardlinks all the files within the folders. Reason is because I need to remove the unwanted FILES amongst the wanted ones from within folders. I looked into creating hardlinks manually to each folder in Command Prompt but that didn't give me what I needed. I can use XCOPY to create an empty folder tree but manually creating hardlinks to each file is just way too much work. –  J. Chin Aug 20 '13 at 12:06
    
It sounds like you did not try my solution. Did you go to the link?Also, my solution mentions that using the command line will not work well and to NOT use it. –  Damon Aug 20 '13 at 16:06
    
Damon, thank you but no we didn't try yours. I have a more than one set of these files that we need to do this and I have non-techie people doing them later. I didn't want them to accidentally make a bunch of soft-links and then end up messing things up. I will try it myself later when I have some time. Thanks. –  J. Chin Aug 20 '13 at 19:38

Kind of found a "hack" method of getting the results we want for now.

There is a free utility called DirectorySlicer for Windows that helps us "splits" (really it makes "copies") of files into directories of a specified sized-chunks. A bonus feature of this utility is that it uses "hardlinks" if the destination drive is the same as the source and is NTFS.

So here is the "hack" we just did. We specified a new destination and specified a target directory size of 1TB, effectively larger than the entire source so it creates one directory. Seconds later we have a bunch of directories with hardlinks to the source files, just want we wanted (almost, it create an extra directory level, but that can be fixed easily enough).

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.