0

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?

nadun
  • 393
  • 1
  • 4
  • 14
DTM450
  • 3
  • 3

1 Answers1

1

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.

Compo
  • 36,585
  • 5
  • 27
  • 39
  • Could you go into detail on the target parameters please – DTM450 Dec 24 '16 at 02:39
  • **%1** is the dropped file with double quotes if necessary, **%~1** is the dropped file without outer double quotes. **%~n1** is the dropped file base name only. **%~x1** is the dropped file extension only. – Compo Dec 24 '16 at 10:15
  • What about the >Nul and 2>&1 part? – DTM450 Dec 25 '16 at 12:34
  • That simply redirects both stdout, _(1>)_, and stderr, _(2>)_, to `Nul` such that you don't see any output at all from the command. As the command window will close almost immediately you'll be unlikely to actually see that output anyhow. – Compo Dec 25 '16 at 12:40