I'm interested in creating a batch file that will mklink the same directory to multiple exit directories, but it's tedious to type out the separate folder names. Is there a way to reference a list of names for the folders instead?
The tedious method-
mklink /j "B:\apple" "C:\test"
mklink /j "B:\orange" "C:\test"
mklink /j "B:\banana" "C:\test"
Is there a way to simplify this down to something like:
mklink /j "B:\foldername" "C:\test"
Then foldername will automatically be replaced by possible folder names from a list?
You should really look at the "for" command in batch files. The for command can read input from a file or read the output from other commands and act on that output. As an example, you could use the following to read data from a text file called "input.txt" and run your command on the data read from each line:
for /f %%i in (input.txt) do (
mklink /j "%%i" "C:\test"
This can get much more complicated, but the above will get you started. Let me know if you run into a specific problem with the above example and I'll see if I can help. I'd suggest reading through the output of for /? several times.