cd to symlink's resolved path [solved]

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
daubmannus
New Member
New Member
Posts: 1
Joined: 2017-08-30, 17:58 UTC

cd to symlink's resolved path [solved]

Post by *daubmannus »

Is there some way in TC to use output of a script in its CD command's params or to change directory in TC panel with cmd?

E.g., I could go to target directory of symbolic link with bat+cygwin:

wreadlink.bat gives path:

Code: Select all

@echo off
set PARAM=%1
REM escape double quotes!
set PARAM=%PARAM:"=\"%

bash -c "cygpath -m \"$(readlink -f %PARAM%)\""
and cd-slink.bat (with symlink as argument) goes there:

Code: Select all

@echo off
for /f usebackq %%F in (`wreadlink "%1"`) do cd %%F
Also, I've installed NTLinks plugin, but have no idea, how to use its fields except in 'Change attributes' dialog.

Sorry, I'm a total newbie with TC and in rather poor command of dos batch scripting, so thanks for any hint on subject.

Is there some way in TC to use output of a script in its CD command's params or to change directory in TC panel with cmd?

E.g., I could go to target directory of symbolic link with bat+cygwin:

wreadlink.bat gives path:

Code: Select all

bash -c "cygpath -m $(readlink -f %1)"
and cd-slink.bat (with symlink as argument) goes there:

Code: Select all

for /f usebackq %%F in (`wreadlink "%1"`) do cd "%%F"
Also, I've installed NTLinks plugin, but have no idea, how to use its fields except in 'Change attributes' dialog.

Sorry, I'm a total newbie with TC and in rather poor command of dos batch scripting, so thanks for any hint on subject.

UPD: solved!
I've find solution at stackoverflow (I can't post link, so google: 'how to open folder with an already running total commander in batch')
So, I've made new batch file as follows:

Code: Select all

for /f usebackq %%F in (`wreadlink "%1"`) do C:\totalcmd\TOTALCMD.EXE /O /T /S /R="%%F"
parameters explanation:

Code: Select all

/O If Total Commander is already running, activate it and pass the path(s) in the command line to that instance (overrides the settings in the configuration dialog to have multiple windows)
/T Opens the passed dir(s) in new tab(s) (for usage with /O)
/R= Set path right window
/S Interprets the passed dirs as source/target instead of left/right (for usage with /O).
After that I've created a command

Code: Select all

[em_ResolveSymlink]
cmd=%COMSPEC% /K
param=cd-slink-tc.bat "%P%N" && exit
menu=Resolve Symbolic Link to Dir in Opposite Panel
iconic=1
...and asign it a sortcut (Ctrl+Alt+F6)
Post Reply