change directory using pattern

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
ilabutin
Junior Member
Junior Member
Posts: 2
Joined: 2017-10-30, 22:17 UTC

change directory using pattern

Post by *ilabutin »

I have folders in the tree like that:
c:\root\projA\trunk\
c:\root\projA\branch\v1
c:\root\projB\trunk\
c:\root\projB\branch\v1

Basically each "project" has subfolders which start with identical structure (both will have "trunk", both will have "branch\v1", etc.

Now, if my current directory is c:\root\projA\trunk (or any subdirectory) I want to move to c:\root\projB\trunk with hotkey.
And the other way around: if I'm in c:\root\projB\branch\v1\foo\bar, I want to move to c:\root\projB\branch\v1 (without any suffix) with [preferably] same hotkey.

I tried to play with button bar, but I was not able to come up with something that works. I already have PowerShell function that accepts current path and returns correct destination path, so maybe I can somehow use it.
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: change directory using pattern

Post by *Stefan2 »

ilabutin wrote:...

Now, if my current directory is
c:\root\projA\trunk

I want to move to
c:\root\projB\trunk

with hotkey.


And the other way around:
if I'm in c:\root\projB\branch\v1\foo\bar,
I want to move to c:\root\projB\branch\v1
with [preferably] same hotkey.
...

Utilize a script (DOS batch PowerShell AutoHotkey VBS ...)

The TC parameter %P give you the path from current active panel.
(right click a button > choose "Change..." > in button dialog press F1-key and read)


With that %P-info, modify the path (the string) as you like with the capabilities of the script language.
(If %P=A Then New=B Else New=A)


Next call a TC command to open that new created path.
"%Commander_Exe%" /O /S /R="my new path"
(See F1 help > Config & Switches > Command line parameters)





For examples see there > viewtopic.php?t=47299




More can be found in the forum by searching the above used keywords....




I guess for this which
c:\root\projB\branch\v1\foo\bar,
c:\root\projB\branch\v1
you have to think about an own rule / work around :D



 
ilabutin
Junior Member
Junior Member
Posts: 2
Joined: 2017-10-30, 22:17 UTC

Post by *ilabutin »

Yes, thanks!
I didn't know the trick with %Commander_Exe% /O /S /L

As I said I already have powershell script that knows how to calculate destination path given the source path.
So, I only added

& "$Env:Commander_Exe" "/O" "/S" "/L=\"$destinationPath\""

to it.
Then I added new user command to Start menu and mapped cm_* command to keyboard shortcut.

Thanks for help.
Post Reply