Get symlink target path

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
Notme
Junior Member
Junior Member
Posts: 14
Joined: 2011-06-02, 09:05 UTC

Get symlink target path

Post by *Notme »

Hi

How can I get (preferably copy to clipboard, or navigate to) the target path a symlink is pointing to? I know Ctrl+PgDn Ctrl+Left(Right) works with ".lnk" files, but I am talking about those, created using mklink.

For example if I:

Code: Select all

mklink /d c:\symdir c:\truedir
and then want to get c:\truedir.
Or if I have a file inside c:\symdir\, like c:\symdir\file.txt, how can I get c:\truedir\file.txt?

I know this is achievable using:

Code: Select all

powershell.exe (Get-Item c:\symdir).Target
and am considering creating a button, or a custom command involving this, but isn't there a better solution?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Get symlink target path

Post by *ghisler(Author) »

You need to use a content plugin like NTLinks:
http://totalcmd.net/plugring/ntlinks.html
Author of Total Commander
https://www.ghisler.com
Notme
Junior Member
Junior Member
Posts: 14
Joined: 2011-06-02, 09:05 UTC

Re: Get symlink target path

Post by *Notme »

Thanks for the reply.
Using NTLinks, would the approach be creating a custom columns mode and then copying all the columns (i.e. "...With All Details") from the "Mark" menu?
I'd rather assign it a keyboard shortcut or a button, but don't know how I can use plugin fields there.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Get symlink target path

Post by *ghisler(Author) »

Yes, custom columns are probably the way to go.

You can use content plugins in these locations:
1. Commands - Search on the third page, e.g. to find symlinks with certain targets
2. View - Custom columns: It allows you to define columns of your choice for the normal file lists
3. Configuration - options - thumbnails: Here you can define fields (e.g. the resolution) to be shown under the thumbnails
4. Configuration - options - display - "+" button: Allows to define hints (tooltips) when hovering with the mouse over a file
5. Multi-rename tool
Author of Total Commander
https://www.ghisler.com
Notme
Junior Member
Junior Member
Posts: 14
Joined: 2011-06-02, 09:05 UTC

Re: Get symlink target path

Post by *Notme »

Ok, so I ended up adding a column [=ntlinks.Obj_RealPath.Natural] and assigning a keyboard shortcut to cm_CopyFpFileDetailsToClip. Then I am extracting that column from clipboard using Autohotkey. I don't need to actually see the column and was trying to set it's width to 0, but there is still about a pixel, or two of it showing. That's, however, just a cosmetic issue.

Thanks for your help!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Get symlink target path

Post by *ghisler(Author) »

Btw, since Total Commander 10.50 you can copy just that column with a parameter:
09.03.22 Added: cm_CopyFileDetailsToClip, cm_CopyHdrFileDetailsToClip etc. now accept parameter to copy only specific columns (1=name+ext, 2=first custom, 4=second custom etc.) in normal, comments, and custom columns view. Parameter 1 alone copies full list with headers, for backwards compatibility (32/64)

So
cm_CopyFpFileDetailsToClip 2
would copy just the first column after name and extension, or
cm_CopyFpFileDetailsToClip 3
would copy name+extension plus the first column.
Author of Total Commander
https://www.ghisler.com
Post Reply