Absolute path of link, how ??

You have encountered a problem using Far Manager? Here you can get help.
Post Reply
skorefish
Posts: 8
Joined: Fri 16 Jan, 2015 11:50

Absolute path of link, how ??

Post by skorefish »

Hello,

I just installed FAR and I like it so far :wink:

I find it very useful to have a directory with links to my favourite places.
But when I click the link I only get the relative path starting from that directory.

How can I get the absolute path? I want to copy it in my clipboard.
skorefish
Posts: 8
Joined: Fri 16 Jan, 2015 11:50

Link with absolute path???

Post by skorefish »

hallo,

is it possible to create links to dir with an absolute path?
skorefish
Posts: 8
Joined: Fri 16 Jan, 2015 11:50

Absolute path of link, how ??

Post by skorefish »

well,

when I create a link in windows I can see the absolute path in explorer.
User avatar
John Doe
Бюрократ
Posts: 13807
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 73 times
Been thanked: 426 times
Contact:

Absolute path of link, how ??

Post by John Doe »

skorefish wrote: I want to copy it in my clipboard.
Try execute this in cmdline: lua:far.CopyToClipboard (far.GetReparsePointInfo (APanel.Current))
skorefish
Posts: 8
Joined: Fri 16 Jan, 2015 11:50

Absolute path of link, how ??

Post by skorefish »

Wow thx, it realy works.. :Yahoo!:

Where can I learn code like this ?
User avatar
John Doe
Бюрократ
Posts: 13807
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 73 times
Been thanked: 426 times
Contact:

Absolute path of link, how ??

Post by John Doe »

%FARHOME%\Encyclopedia

Here is ready to use macro:

Code: Select all

Macro { description="Copy link destination to clipboard";
  area="Shell"; key="AltShiftIns";
  id="43F9FF40-70B0-4308-B8C8-7262FB905757";
  condition=function()
    return not (APanel.Selected or APanel.Plugin and band(APanel.OPIFlags, far.Flags.OPIF_REALNAMES)==0)
  end;
  action=function()
    local path = far.GetReparsePointInfo(APanel.Current)
    if path and path~="\\" then
      far.CopyToClipboard (path)
    else
      Keys"AKey"
    end
  end;
}
skorefish
Posts: 8
Joined: Fri 16 Jan, 2015 11:50

Absolute path of link, how ??

Post by skorefish »

you make my day !!! Thx a lot.
User avatar
John Doe
Бюрократ
Posts: 13807
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 73 times
Been thanked: 426 times
Contact:

Absolute path of link, how ??

Post by John Doe »

Code: Select all

local ACTIVE,PASSIVE = 0,1;
Macro { description="Goto link destination";
  area="Shell"; key="CtrlPgUp CtrlShiftPgUp";
  id="256DFE10-768F-4DC6-9455-6FD5BD753D91";
  condition=function()
    return not APanel.Plugin or bit64.band(APanel.OPIFlags, far.Flags.OPIF_REALNAMES)~=0
  end;
  action=function()
    local path = far.GetReparsePointInfo(APanel.Current)
    if path then
      local filename
      if not APanel.Folder then
        path,filename = path:match"^(.-)([^\\]+)$"
      end
      Panel.SetPath(mf.akey(1,1):find"Shift" and PASSIVE or ACTIVE, path, filename)
    else
      Keys"AKey"
    end
  end;
}
https://t.me/FarManager — Telegram чат
User avatar
John Doe
Бюрократ
Posts: 13807
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 73 times
Been thanked: 426 times
Contact:

Absolute path of link, how ??

Post by John Doe »

Code: Select all

local HARDLINK = 4
local SYMLINK = 6
Macro { description="Goto link destination";
  area="Dialog"; key="CtrlPgUp";
  id="9EE3929C-09D8-4C81-8EA6-EDFDC0A25D91";
  condition=function()
    return Dlg.Id==far.Guids.FileAttrDlgId
  end;
  action=function()
    local path
    if Menu.Value~="" then
      Keys"Enter"
      path = Dlg.GetValue(HARDLINK)
    elseif Dlg.GetValue(HARDLINK)~="" then
      Dlg.SetFocus(HARDLINK)
      Keys"CtrlDown"
      return
    else
      path = Dlg.GetValue(SYMLINK)
    end
    if path~="" then
      local filename
      if not APanel.Folder then
        path,filename = path:match"^(.-)([^\\]+)$"
      end
      Panel.SetPath(0, path, filename)
      Keys"Esc"
    end
  end;
}
https://t.me/FarManager — Telegram чат
User avatar
HaRT
Moderator
Posts: 10822
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 221 times
Been thanked: 358 times

Absolute path of link, how ??

Post by HaRT »

John Doe wrote: Mon 18 Mar, 2024 01:03 if not APanel.Folder
Is this check relevant in the File Attributes Dialog?
Фар есть инструмент, а не нянька. © 2009 DrKnS
User avatar
John Doe
Бюрократ
Posts: 13807
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 73 times
Been thanked: 426 times
Contact:

Absolute path of link, how ??

Post by John Doe »

HaRT wrote: Mon 18 Mar, 2024 01:29 Is this check relevant in the File Attributes Dialog?
Absolutely relevant, just press CtrlA on any folder
https://t.me/FarManager — Telegram чат
User avatar
HaRT
Moderator
Posts: 10822
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 221 times
Been thanked: 358 times

Absolute path of link, how ??

Post by HaRT »

John Doe wrote: Mon 18 Mar, 2024 01:53 Absolutely relevant, just press CtrlA on any folde
Now I see how that can be useful for directory junctions and symlinks, but not for regular folders.
IMHO both scripts (for Shell and for Dialog) should include a in their condition.
Ideally, the Dialog script has to be disabled for multiple selected panel items too.
Фар есть инструмент, а не нянька. © 2009 DrKnS
User avatar
John Doe
Бюрократ
Posts: 13807
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 73 times
Been thanked: 426 times
Contact:

Absolute path of link, how ??

Post by John Doe »

Cases with regular folders / multiple objects are now covered by line if path~="" then.
But your idea really makes sense if we want to have another macro on CtrlPgUp in this dialog, for plain files/folders.
https://t.me/FarManager — Telegram чат
User avatar
HaRT
Moderator
Posts: 10822
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 221 times
Been thanked: 358 times

Absolute path of link, how ??

Post by HaRT »

John Doe wrote: Mon 18 Mar, 2024 03:16 Cases with regular folders / multiple objects are now covered by line if path~="" then.
Indeed (though it's not immediately obvious at a glance).
It would be nice if this script also worked for the case of multiple hard links: the user opens the drop-down list of the links, chooses the link of interest, and invokes the script, and the script picks up the selected item and jumps to it.
Фар есть инструмент, а не нянька. © 2009 DrKnS
User avatar
John Doe
Бюрократ
Posts: 13807
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 73 times
Been thanked: 426 times
Contact:

Absolute path of link, how ??

Post by John Doe »

HaRT wrote: Mon 18 Mar, 2024 04:05It would be nice
Just implemented
https://t.me/FarManager — Telegram чат
Post Reply

Return to “Support and Troubleshooting”