Page 1 of 1

limitating parent folder upping to a drive root ?

Posted: 30 May 2018 04:02
by leomain
i would like to know if, via a script, it could be possible to put a limitation for going up to a specific parent folder, as like as X:\
-> would be useful sometimes to limitate unwanted multiple clicks on Up parent folder icon or multiple backpace key actions

Re: limitating parent folder upping to a drive root ?

Posted: 30 May 2018 06:28
by highend
Create a user defined command which runs this script:

Code: Select all

    $maxRootLvl = 2;

    $upLvl = regexreplace(<curpath>, "\\[^\\]+$") . "\";
    $cntSep = gettoken($upLvl, "count", "\") - 1;
    // Local paths
    if (substr(<curpath>, 0, 2) != "\\") {
        $distance = $maxRootLvl + 1;
    // Network paths
    } else {
        $distance = $maxRootLvl + 3;
    }
    if ($cntSep < $distance) { end true; }
    goto $upLvl;
Change the $maxRootLvl variable to either
0, 1, 2, ...

E.g.:
Local path: C:\Users\%USERNAME%\AppData\Roaming
0 would limit it to: C:\
1: C:\Users
2: C:\Users\%USERNAME%
etc.

Same for network paths
Network path: \\server\dlna\movies
0 would limit it to: \\server
1: \\server\dlna
2: \\server\dlna\movies
etc.

Remove backspace from the keyboard shortcut for the "Go - Up" command
and bind it to the user defined command

Additionally, add a new user button to the toolbar and use the id of that user defined command
in the "On left click field"
The icon could e.g. be: ":up" (without the double quotes)