Change directory with relative path

English support forum

Moderators: Hacker, petermad, Stefan2, white

User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

BTW you can create LNKs to folders within TC and then edit them in order to insert %COMMANDER_DRIVE% into them. I tried it, Windows allows inserting existing envvar. But such envvar will work in right way regardless of drive letter, the only rule is to execute such LNK file within TC that is started from that USB stick!

So, you create a link to folder to ?:\portables\Internet\Hist\ using e.g. Ctrl+Shift+F5, and then you edit LNK properties using e.g. Alt+Enter (within TC!) and change both path and working dir to %COMMANDER_PATH%:\portables\Internet\Hist\.

TC processes LNKS to dirs internally: on Enter it switches to that dir, and on Ctrl+Left/Right it opens that dir in left/right panel.
liamZ
Junior Member
Junior Member
Posts: 23
Joined: 2014-12-28, 20:04 UTC

Post by *liamZ »

Thanks Zoster your help, I didn't kown about setx.

And thanks MVV. The %COMMANDER_DRIVE% in the shortcut within TotalCommander works for the target working directory too, and even the icon path of the shortcut.

Both methods work fine, but a much better solution will be to find a way to work with relative paths.

It's not possible to do it with TC?
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

You can't use LNKs because of non-absolute path issues. And there are no internal TC link files. However you can place BAT files (or CMD files) instead of LNKs with the only line to call TC in order to switch dir, e.g.:

Code: Select all

@start "" "%COMMANDER_EXE%" /O /S /L="%~dp0\..\..\mydir"
If you give a prefix for all such files (e.g. name them like ~cd mydir.cmd or $mydir.cmd), they will be pretty visible and grouped together.

BTW there is another interesting way. You choose any extension (like TCD) and associate it internally (using File - Internal Associations) with some batch file having following contents:

Code: Select all

@echo off
for /f "usebackq delims=" %%p in (`type %1`) do start "" "%COMMANDER_EXE%" /O /S /L="%~dp1\%%p"
Then you'll be able to simply write relative paths into TCD files, e.g. ..\..\mydir, and execute them by Enter. You can even assign an icon for TCD files so it may be even nicer. However Ctrl+Left/Right won't work here.
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

liamZ wrote:Both methods work fine, but a much better solution will be to find a way to work with relative paths.
To be honest, I still don't get your obsession with relative paths. Sooner or later they will get you into trouble.
Just put your portable programs and folders on a button bar or the directory hotlist using the %COMMANDER_DRIVE% or %COMMANDER_PATH% variable and you're done.

I've got a portable TC installation with ~70 tools, plus numerous plugins and it works without a hitch.

If those programs are truly portable and you start them from TC all is fine.
Is there something that's actually not working?
User avatar
milo1012
Power Member
Power Member
Posts: 1158
Joined: 2012-02-02, 19:23 UTC

Post by *milo1012 »

I agree with ZoSTeR.
%COMMANDER_DRIVE% and %COMMANDER_PATH% have been around for several years and work fine for all situations I encountered.

But if you REALLY need to use relative paths, NiftyLink is probably the only tool that does exactly what you intended.
Just read the docs for how to set everything up (it's actually quite easy).
TC plugins: PCREsearch and RegXtract
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

In case of portable TC it is not a good idea to associate something with TC tools.

Actually TCFS2 may also send relative paths:

Code: Select all

TCFS2.exe /ef "tem(`em_Cd ..\..\mydir`)"
The only prerequisite is user-command em_Cd with command cd and parameter %A:

Code: Select all

[em_Cd]
cmd=cd
param=%A
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

alphonse68 wrote:This seems to no longer work on TC 8.52a, Win X... ?
Did you have modified that button to a path you have in real? ..."mydir" is just an example.


If you need help, right click that button, choose 'Copy' and paste in here.




 
Post Reply