How to make a link for a directory or file using TC?

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
cheming
Member
Member
Posts: 154
Joined: 2004-05-07, 14:38 UTC
Location: China

How to make a link for a directory or file using TC?

Post by *cheming »

I can use mklink.exe for it , is there a handy method to do this in the TC?
User avatar
Clo
Moderator
Moderator
Posts: 5731
Joined: 2003-12-02, 19:01 UTC
Location: Bordeaux, France
Contact:

IC

Post by *Clo »

2cheming

:) Hello !

• You can use the internal command cm_CreateShortcut OR 1004 for a button, menu item or keyboard shortcut.
- You can also define how the created *.lnk file will be named :
<wincmd.ini> [Configuration]
AppendLnk=Flag
• Link files (*.lnk) will be created as follows:
¤ 0: file.ext –> file.lnk
¤ 1: file.ext –> file.ext.lnk
:mrgreen: KR
Claude
Clo
#31505 Traducteur Français de TC French translator Aide en Français Tutoriels Français English Tutorials
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hi, Claude.

I am afraid creating a Windows shortcut (cm_CreateShortcut or <Ctrl-Shift-F5>) is not equivalent to creating a symbolic link using mklink.
To the best of my kowledge, Total Commander natively has got no commands to create symbolic links, hardlinks and junctions. This is, however, what mklink does.

You may check out this somewhat confusing thread way back from 2006. Confusing, too, because there is a tendency of mixing hardlinks and symbolic links. How create symbolic link in TC6?.

Another one: (TIP) Creating symbolic links on NTFS

"File not found" when running 'mklink' DOS command. Do not miss the advice given on integrating mklink as a T.C. user defined command or on the NTFSLinks addon for T.C..
(Beware, NTFSLink may or may not be Unicode compliant, so it may or may not co-operate correctly with Total Commander 7.50a. Flint might know?!)

Kind regards,
Karl
Last edited by karlchen on 2009-11-30, 23:14 UTC, edited 1 time in total.
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Re: How to make a link for a directory or file using TC?

Post by *karlchen »

Hello, cheming.
I can use mklink.exe for it , is there a handy method to do this in the TC?
mklink.exe? To the best of my knowledge, mklink is an internal command of cmd.exe available on recent Windows versions, i.e Vista and above.
On older Windows versions, you had to use linkd.exe and junction.exe instead.

Karl
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

This is what I use for junctions under Win2K, it could fairly easily be adjusted for mklink instead.

2 Buttons in SubBar (on ButtonBar/ToolBar):
Junction CREATE
Command: cmd.exe /c mjunction.cmd -ln
Parameters: %T %S

Junction DELETE
Command: cmd.exe /c mjunction.cmd -d
Parameters: %T %S

Code: Select all

:: 
:: Command: mjunction.cmd
::
:: Usage1: Select Folders in (Source) Pane; Junctions created in Target Pane.
:: Usage2: Select Folders in (Source) Pane; Junctions deleted
::
@ECHO OFF
CLS

IF "%~1"=="-d" GOTO:DELETE_JUNCTION
:CREATE_JUNCTION
IF "%~3" == "" GOTO:EOF
junction "%~2%~3" "%~3"
SHIFT /3
GOTO:CREATE_JUNCTION

:DELETE_JUNCTION
IF "%~2" == "" GOTO:EOF
junction -d "%~2"
SHIFT /2
GOTO:DELETE_JUNCTION
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

BTW symlinks are new in Vista/7 and you need admin rights to create them. Also them have some not very useful features - e.g. if you have symlink you won't see real file/folder date, you will see only symlink date, size field also is not updated as I see.
So I suggest to create only junctions using /J command line switch for mklink command (note that in Vista/7 it is a command, not a separate executable, so you can't use it w/o cmd.exe).
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3893
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Post by *sqa_wizard »

2Balderstrom: You don't need a button at TC to delete a junction !
TC safely removes the junction to a folder (leaves the files untouched) by simply pressing DEL or F8 key :)

!!! Caution !!! Don't try it with Windows Explorer of an OS prior to Vista !
This will first delete the files and then remove the junction !
#5767 Personal license
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

@sga_wizard, TC may handle junctions correctly for deletion, and if so it's one of the few things it does do correctly with them.

The only reason to not delete junctions with Explorer is it will drop the junction into the Recycle-Bin, and when the Recycle-Bin is emptied: Windows parses the junction and deletes the real files in the real/actual directory.

Ghisler also refuses to allow us to disable the Annoying pop-up every time a file is deleted: Unless we use "Explorer Delete method" -- which then means junction deletions are no-longer safe.

TC's delete-confirmation-popup is also Exactly-the-same in it's phrasing whether or not the files will go to the Recycle bin or not. TC also does not distinguish between Shift+Del and normal Delete, the phrasing of the pop-up is exactly the same.

None of that behaviour is acceptable to me. My middle-mouse button for every other application is "Delete"; for TC I made it be: CTRL+Delete & I defined a user-command to call "Recycle.exe" for Ctrl+Del.

I don't get pop-ups for normal deletes any longer.
I do get pop-ups for SHIFT+Deletes (which do not go to the recycle bin).
And I delete junctions from the SubBar dropDown menu.

TC still doesn't handle junction move/copy how I believe it should. If I drag-move a junction from a current dir into a subFolder (same panel) or to the parent folder [..] then TC will move the junction. Yet if I drag-move a junction from one panel to the other, TC creates a folder and copies the contents of the junction. Thus I am forced to do a Windows Cut/Paste to move the junction.

As MVV noted here in regards to the new Symlinks Report broken reparse points after copying/moving,
The * junction bug I reported in 2005 wasn't fixed for 4 years (in one of the recent TC beta's or the 7.50 final)

*(1/ Drag/Move a junction: Explorer Moves the Junction; whereas TC would: Create a Folder, and MOVE all contents of Junction to the new folder.

The current fix is suboptimal as it is inconsistent behaviour whether you drag within a panel or to the other panel.
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3893
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Post by *sqa_wizard »

The current fix is suboptimal as it is inconsistent behaviour whether you drag within a panel or to the other panel.
Yes, I agree. It is time for a proper detection of junctions and use a individual handling, as junctions get used more and more since Vista and now Win7.
#5767 Personal license
Post Reply