Create symbolic link (MKLINK /D)

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

User avatar
petermad
Power Member
Power Member
Posts: 16021
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.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
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" ) )
User avatar
Dr. Yukon
Junior Member
Junior Member
Posts: 2
Joined: 2024-09-25, 10:04 UTC
Location: Russia, "Eastern" Space Center
Contact:

Re: Create symbolic link (MKLINK /D)

Post by *Dr. Yukon »

My way: menu [Start] - [Change Start Menu...]

Start menu:
-Simlink
Send folder
Get folder
Send file
Get file
--
Command for all options:
cmd
Parameters for option:
"Send folder":
/C mklink /j %T%N %P%N
"Get folder":
/C mklink /j %P%M %T%M
"Send file":
/C mklink /h %T%N %P%N
"Get file":
/C mklink /h %P%M %T%M
/d key is banned in our company
Environmental Engineer of the Russian "Eastern" Space Center
Post Reply