Which is the best way to archieve this? I was thinking on a batch script that takes a source folder and a destination folder as inputs, and then iterates recursively over the source folder and for each file creates a hard link to that file (with the same name) in the destination folder.
hardlink.bat "src dir" "dst dir"
results:
->src dir\file1 <==> dst dir\file1
->src dir\subdir\file2 <==> dst dir\subdir\file2
I tried doing this with a for loop, but my experience with batch scripting is limited, and I don't know how to split the source folder name to recreate the same directory structure in the destination folder. Any hints would be greatly appreciated!
P.D: The solution could use any scripting language. I currently have python 2.7.3 installed
I like the free Link Shell Extension which gives you GUI tools to create hardlinks and is integrated right into Explorer.
If you want to do it from a script, you can execute Windows' fsutil utility. Another very good free alternative is the junction utility from SysInternals..
Either can be invoked from a batch script. Likewise, to execute one or the other from a Python script you could use the os.system()
function or possibly an instance of the subprocess.Popen()
class.