Command Button to open tab to specific folder

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
xkxtnt
Junior Member
Junior Member
Posts: 5
Joined: 2016-01-19, 19:21 UTC

Command Button to open tab to specific folder

Post by *xkxtnt »

Is there a way to create a button that will open a folder in target panel depending on the current path in source panel?

For example, if the source panel path is \\network1\mdf\2014\04\23, I want the target panel to go to log folder \\network1\log\2014\04\23 with the same date after clicking on the button.

The only difference is the mdf and log part in the folder, the rest are the same. But of course the date part \2014\04\23 will change depending the folder I am in.

Any help is greatly appreciated!
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Batch/PoSh: Modify path and open it in target panel

Post by *Stefan2 »

Hi and welcome xkxtnt

You may want to try this BATCH, executed from an button:

Code: Select all

@ECHO OFF
REM Batch for Total Commander
REM 
REM Found at http://ghisler.ch/board/viewtopic.php?p=304419#304419
REM 
REM Stefan, 2016-01-19
REM 
REM Purpose:
REM 1. Get current path from source panel
REM 2. Change '\mdf\' part to '\log\'
REM 3. Change target pane to wanted path
REM 
REM For example, if the source panel path is \\network1\mdf\2014\04\23, 
REM I want the target panel to go to folder \\network1\log\2014\04\23 
REM The only difference is the mdf and log part in the folder, the rest are the same.
REM 
REM 
REM 
REM Usage:
REM Create a TC button
REM CMD: path\to\this\SyncPath.cmd
REM PARAM: "%P"
REM 
REM Have wanted source path open in one panel.
REM Execute this batch.
REM Awaited Result: target panel is changed to wanted path.
REM 


SET TARGET=%~1
ECHO %TARGET%

SET TARGET=%TARGET:\mdf\=\log\%
ECHO %TARGET%

ECHO Open new path in other (target) panel:
"%Commander_Exe%" /O /S /R="%TARGET%"

REM PAUSE
REM EOF




In button-modify dialog, press F1 key to learn more about.




- - -

A PowerShell script can be found over there> http://ghisler.ch/board/viewtopic.php?t=42438


Needs no extra batch file.

Code: Select all

CMD: PowerShell -NoExit -NoProfile -ExecutionPolicy Bypass

PARAM: $TARGET='%P' -replace('\\mdf\\', '\log\'); """$env:Commander_Exe /O /S /R=$TARGET"""; 




 
User avatar
nsp
Power Member
Power Member
Posts: 1952
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

out of the box, it is not possible to have such as in a button parameter you cannot use any regexp, wdx, renaming scheme or scripting....
Anyhow, you can do it with an automation tool like powerpro, ahk, autoit, powershell, awk....
What you can do is to have a kind of mapping table to tranform current path %P and change TC target folder ...
xkxtnt
Junior Member
Junior Member
Posts: 5
Joined: 2016-01-19, 19:21 UTC

Post by *xkxtnt »

Thanks Stefan! I will try it out.
Post Reply