Change directory with relative path
Moderators: Hacker, petermad, Stefan2, white
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.
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.
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?
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?
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.:
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:
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.
Code: Select all
@start "" "%COMMANDER_EXE%" /O /S /L="%~dp0\..\..\mydir"
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"
To be honest, I still don't get your obsession with relative paths. Sooner or later they will get you into trouble.liamZ wrote:Both methods work fine, but a much better solution will be to find a way to work with relative paths.
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?
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).
%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
In case of portable TC it is not a good idea to associate something with TC tools.
Actually TCFS2 may also send relative paths:
The only prerequisite is user-command em_Cd with command cd and parameter %A:
Actually TCFS2 may also send relative paths:
Code: Select all
TCFS2.exe /ef "tem(`em_Cd ..\..\mydir`)"
Code: Select all
[em_Cd]
cmd=cd
param=%A