I have a directory
a\ containing files and sub-directories that I want to copy into path
b\ where instead of copying the files I want to perform a call to
MKLINK <link> <target> on each file into the new path rather than performing an actual copy.
So if I have a directory:
Z:\a\file1.txt Z:\a\file2.txt Z:\a\some_path\file3.txt Z:\a\some_path\file4.txt
And I copy links from path
b\ the result will look like:
Z:\b\file1.txt <<===>> z:\a\file1.txt Z:\b\file2.txt <<===>> z:\a\file2.txt Z:\b\some_path\file3.txt <<===>> z:\a\some_path\file3.txt Z:\b\some_path\file4.txt <<===>> z:\a\some_path\file4.txt
The directory hierarchy is to be preserved as non-link folders in the event that the target directory does not have a matching folder structure. Note that only the files are links.
A successful test will succeed where
Z:\b is an empty directory,
Z:\b contains a folder
Z:\b\some_path, and either previous tests but
Z:\b my already contain files of the same name; conflicts are ignored and no link is created for them.
How can I do this using a batch file with no additional dependencies beyond what is available in a standard Windows 10 installation?