How do I create a symbolic link using a batch script in windows?

21,987

You utilise the mklink command:

for /f "delims==" %%k in ('dir "d:\Search Path\File Prefix*.*" /s /b') do (
mklink "d:\Target Directory\" "%%~k"
)

And that should solve your problem. mklink /? for more info.

Mona.

Share:
21,987
user3405604
Author by

user3405604

Updated on March 12, 2020

Comments

  • user3405604
    user3405604 about 4 years

    I am currently using the following script to copy all files with a certain prefix to a target directory:

    for /f "delims==" %%k in ('dir "d:\Search Path\File Prefix*.*" /s /b') do copy "%%k" "d:\Target Directory\"
    

    This works fine but I would like to instead create a symlink to the files incase of any file changes. Please can someone advise how I could do this?

    Many Thanks