Mklink Via Drag And Drop Onto Batch

183 views Asked by At

What I need is a batch file that when I drag a file onto it it creates a hardlink with the link name the same as the file dropped onto the script with (HL) added to link name.

e.g. test.txt [original] --> test(HL).txt [hardlink]

I've tried using this but it doesn't work.

mklink /h %~n1(HL).%~x1 %~nxf

How can I get this working?

1

There are 1 answers

4
Compo On BEST ANSWER

You got your target wrong:

@MkLink /H "%~n1[HL]%~x1" "%~1">Nul 2>&1

I changed the parentheses to square brackets because I disagree with their use in file/folder names, that choice is of course yours to make.