Can batch file affect TC's current dir?
Moderators: Hacker, petermad, Stefan2, white
Can batch file affect TC's current dir?
Lets say a folder's contents are shown in TC. One of the files is a batch. Can it contain a special CD command (i.e. TC-CD) which will change TC's directory?
- Wanderer -
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.
Re: Can batch file affect TC's current dir?
Your batch can start TC again with the /o parameter and the path to the new dir you want.
Examples:
%COMMANDER_EXE% /O /L=path_for_left /R=path_for_right
or
%COMMANDER_EXE% /O /S path_for_active path_for_passive
Examples:
%COMMANDER_EXE% /O /L=path_for_left /R=path_for_right
or
%COMMANDER_EXE% /O /S path_for_active path_for_passive
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.55 RC1 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
TC 11.55 RC1 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
Re: Can batch file affect TC's current dir?
Nope, thanks for the idea but i don't want to achieve that. Sometimes in some folders i have text files containing info about files in other folders. I thought it would be nice to transform them to batch files to change TC's panel to that folder...
- Wanderer -
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.
Re: Can batch file affect TC's current dir?
How is Horst.Epp's suggestion not accomplishing that?wanderer wrote: 2023-03-08, 11:29 UTC I thought it would be nice to transform them to batch files to change TC's panel to that folder...
Re: Can batch file affect TC's current dir?
I'd like to somehow execute the batch file and change the folder of the active panel of the current TC instance. 

- Wanderer -
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.
Re: Can batch file affect TC's current dir?
2wanderer
Put:
in the first line of your .bat file.
And that what the /O parameter accomplishes:I'd like to somehow execute the batch file and change the folder of the active panel of the current TC instance
Put:
Code: Select all
%COMMANDER_EXE% /O /S drive:\path
Help wrote:/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).
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: Can batch file affect TC's current dir?
Example #1: an approach based on the loadlist command:
Try this (button for a button bar):
Explanation:
If a file under cursor (%P%N) contains any valid files/folders you will see a list of them in an active panel ready for further opening/browsing
Edit
Example #2: an approach based on the above-mentioned command (see @petermad's message):
Let's say we have a text file with a valid file/folder name in it, e.g.
test.txt
then let's put a batch command in wincmd.ini:
then let's put it as a button in a button bar:
then being in a directory of test.txt tap the above button.
Result:
"%commander_path%\Language" folder from "test.txt" will be opened in the Total Commander target panel.
Edit 2
Limitations:
Approach #1: none
All you need just a file under cursor that as you know contains valid files/folders names
Other [than valid file/folders names] data in the file will be ignored (you'll just see a correspondent massage).
Approach #2:
- If the test.txt's file name is unknown you would have to parse it doing something like that:
- If the test.txt contains other text data you would have to parse it to extract only valid files/folders names by doing at least something like that (assuming ":\" part is one of a valid files/folders name):
NB this won't work for the above test.txt content since %commander_path%\Language is swallowing ":\", and only "\" remains available.
- If the test.txt contains more than one valid file/folder name entry, you would rather need somehow to choose which one of them to pass to the Total Commander
Try this (button for a button bar):
Code: Select all
TOTALCMD#BAR#DATA
loadlist
%P%N
wciconex.dll,0
-1
If a file under cursor (%P%N) contains any valid files/folders you will see a list of them in an active panel ready for further opening/browsing
Edit
Example #2: an approach based on the above-mentioned command (see @petermad's message):
Code: Select all
%COMMANDER_EXE% /O
test.txt
Code: Select all
%commander_path%\Language
Code: Select all
[em_test]
cmd=%comspec% /v /c for /f %f in (test.txt) do set folder=%f & %COMMANDER_EXE% /O=!folder!
Code: Select all
TOTALCMD#BAR#DATA
em_test
wciconex.dll
0
10034
Result:
"%commander_path%\Language" folder from "test.txt" will be opened in the Total Commander target panel.
Edit 2
Limitations:
Approach #1: none
All you need just a file under cursor that as you know contains valid files/folders names
Other [than valid file/folders names] data in the file will be ignored (you'll just see a correspondent massage).
Approach #2:
- If the test.txt's file name is unknown you would have to parse it doing something like that:
Code: Select all
cmd=%comspec% /v /c for /f "tokens=* delims=" %f in ('dir /b/a/s ^| find /i ".txt"') do set file=%f & for /f %f in (!file!) do set folder=%f & %COMMANDER_EXE% /O=!folder!
Code: Select all
for /f "tokens=* delims=" %i in ('find ":\" "test.txt"') do echo %i
- If the test.txt contains more than one valid file/folder name entry, you would rather need somehow to choose which one of them to pass to the Total Commander
Last edited by beb on 2023-03-08, 17:03 UTC, edited 6 times in total.
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Re: Can batch file affect TC's current dir?
2petermad
2beb
Thank you both the the interesting ideas! I'll try them, and first of all the /O one, which seems most promising.
2Horst.Epp
I just understood that your post was doing just that! Thanks!
2beb
Thank you both the the interesting ideas! I'll try them, and first of all the /O one, which seems most promising.
2Horst.Epp
I just understood that your post was doing just that! Thanks!
- Wanderer -
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.