limitating parent folder upping to a drive root ?

Discuss and share scripts and script files...
Post Reply
leomain
Posts: 3
Joined: 29 May 2018 06:00

limitating parent folder upping to a drive root ?

Post 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

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: limitating parent folder upping to a drive root ?

Post 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)
One of my scripts helped you out? Please donate via Paypal

Post Reply