Create symbolic link (MKLINK /D)

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

User avatar
petermad
Power Member
Power Member
Posts: 14808
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Create symbolic link (MKLINK /D)

Post by *petermad »

MVV wrote: 2023-09-26, 09:58 UTC Also these user-commands don't support Unicode names.
That can be solved by using codepage 65001:

Code: Select all

[em_junction]
cmd=*%COMSPEC% /C
param=@chcp 65001 && %%COMSPEC%% /C @for /f "usebackq tokens=*" %%i in (`type %WF`) do @( if exist "%P%%~i\" ( mklink /J "%T%%~i" "%P%%~i" ) else ( mklink "%T%%~i" "%P%%~i" ) )
menu=Make directory junction or file symlink in the opposite panel for selected files
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Speeder
Junior Member
Junior Member
Posts: 3
Joined: 2023-09-23, 10:01 UTC

Re: Create symbolic link (MKLINK /D)

Post by *Speeder »

Here is an updated version that supports unicode, and a large amount of input files:

Code: Select all

[em_cpJunction]
cmd=*%COMSPEC% /S /C
param=? ""%%APPDATA%%\GHISLER\usercmd-cplnk.bat" "%UF" "%P" "%T" /J"
menu=Make directory junction or file symlink in the opposite panel for selected files
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
[em_cpSymlink]
cmd=*%COMSPEC% /S /C
param=? ""%%APPDATA%%\GHISLER\usercmd-cplnk.bat" "%UF" "%P" "%T" /D"
menu=Make directory or file symlink in the opposite panel for selected files
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
[em_cpHardJunction]
cmd=*%COMSPEC% /S /C
param=? ""%%APPDATA%%\GHISLER\usercmd-cplnk.bat" "%UF" "%P" "%T" /J /H"
menu=Make directory junction or file hardlink in the opposite panel for selected files
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
[em_cpHardSymlink]
cmd=*%COMSPEC% /S /C
param=? ""%%APPDATA%%\GHISLER\usercmd-cplnk.bat" "%UF" "%P" "%T" /D /H"
menu=Make directory symlink or file hardlink in the opposite panel for selected files
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
[em_cpJunctionClear]
cmd=em_cpJunction,cm_ClearAll
menu=Make directory junction or file symlink in the opposite panel for selected files, clears selection
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
[em_cpSymlinkClear]
cmd=em_cpSymlink,cm_ClearAll
menu=Make directory or file symlink in the opposite panel for selected files, clears selection
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
[em_cpHardJunctionClear]
cmd=em_cpHardJunction,cm_ClearAll
menu=Make directory junction or file hardlink in the opposite panel for selected files, clears selection
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
[em_cpHardSymlinkClear]
cmd=em_cpHardSymlink,cm_ClearAll
menu=Make directory symlink or file hardlink in the opposite panel for selected files, clears selection
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
Batch script to put into the "%APPDATA%\GHISLER\usercmd-cplnk.bat" path:

Code: Select all

:: CpLnk <listfile:utf8-bom> <srcdir> <tgtdir> <dirswitch> [fileswitch]
@echo off
chcp 65001 > nul
set "rmvBom=^|((pause^&pause^&pause^)^>nul^&findstr x*^)"
for /f "tokens=*" %%i in ('type "%~1" %rmvBom%') do ( if exist "%~2%%~i\" ( mklink %4  "%~3%%~i" "%~2%%~i" ) else ( mklink %5  "%~3%%~i" "%~2%%~i" ) )
Post Reply