Branch View - How to set folder depth

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
jaywalker32
Posts: 212
Joined: 27 May 2014 05:24

Branch View - How to set folder depth

Post by jaywalker32 »

Is there a way to set the dept that branch view shows?

I have a few folders, which I want to combine into a single branch view. But, I don't want to see all the sub directories of those folder. Maybe just the top, or 1 level down.

Is this possible? :?:

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

Re: Branch View - How to set folder depth

Post by highend »

In branch view your address bar shows /:flat
at the end

Extend it to:
/md=0:flat

md=n -> maxdepth, n = levels to show

Here is a simple script that allows you to switch the folder depth in branch view by entering a number (default = 0):

Code: Select all

    $ab = tab("get", "term");
    $level = input("Enter recursion level...", "0 = No recursion<crlf>1 = One level deep<crlf>...", 0);
    if !(regexmatches($ab, "(/md=|/maxdepth=)")) { $ab = replace($ab, "/:flat", "/md=$level:flat"); }
    else { $ab = regexreplace($ab, "(/md=|/maxdepth=)(\d)", "$1$level"); }
    goto $ab;
One of my scripts helped you out? Please donate via Paypal

jaywalker32
Posts: 212
Joined: 27 May 2014 05:24

Re: Branch View - How to set folder depth

Post by jaywalker32 »

Excellent! That's exactly it. Thanks!

davidp
Posts: 43
Joined: 04 Feb 2016 08:34

Re: Branch View - How to set folder depth

Post by davidp »

Suppose i want to see up to 3 levels of folder depth,what command should i use.

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

Re: Branch View - How to set folder depth

Post by highend »

md=n -> maxdepth, n = levels to show
One of my scripts helped you out? Please donate via Paypal

davidp
Posts: 43
Joined: 04 Feb 2016 08:34

Re: Branch View - How to set folder depth

Post by davidp »

"Extend it to:
/md=0:flat

md=n -> maxdepth, n = levels to show"

where is n there in the command

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

Re: Branch View - How to set folder depth

Post by highend »

There is already an example in the script...

Code: Select all

"0 = No recursion<crlf>1 = One level deep<crlf>..."
One of my scripts helped you out? Please donate via Paypal

Italianosalvaje
Posts: 1
Joined: 12 Oct 2024 18:24

Re: Branch View - How to set folder depth

Post by Italianosalvaje »

Hi, sorry for necroposting, but I came across this thread and using highend's script I made a couple alterations that I'd like to share:

Original script with a couple modifications (removed the colon from the "/:flat" string in the replace and added a "*" in "\d" in the regexreplace to work correctly when dealing with recursion levels above 9)

Code: Select all

// Get path
$ab = tab("get", "term");
    
    //Ask for user input
    $level = input("Enter recursion level...", "0 = No recursion<crlf>1 = One level deep<crlf>...", 0);
    
    //Check if the path needs to be altered, or simply update the recursion level
    if !(regexmatches($ab, "(/md=|/maxdepth=)")) { $ab = replace($ab, "/flat", "/md=$level:flat"); }
    else { $ab = regexreplace($ab, "(/md=|/maxdepth=)(\d*)", "$1$level"); }
    goto $ab
Scripts to increase/decrease the recursion level by one:

Code: Select all

// Get path
$ab = tab("get", "term");
    //Get recursion level from path and add 1
    $level = replace(regexmatches($ab, "\d*(?=:flat)"), "|","") + 1;

    //Check if the path needs to be altered, or simply update the recursion level    
    if !(regexmatches($ab, "(/md=|/maxdepth=)")) { $ab = replace($ab, "/flat", "/md=$level:flat"); }
    else { $ab = regexreplace($ab, "(/md=|/maxdepth=)(\d*)", "$1$level"); }
    goto $ab;

Code: Select all

// Get path
$ab = tab("get", "term");
    //Get recursion level from path and subtract 1
    $level = replace(regexmatches($ab, "\d*(?=:flat)"), "|","") - 1;
    //Check level is not below 0
    if $level < 0 { $level = 0; }

    //Check if the path needs to be altered, or simply update the recursion level    
    if !(regexmatches($ab, "(/md=|/maxdepth=)")) { $ab = replace($ab, "/flat", "/md=$level:flat"); }
    else { $ab = regexreplace($ab, "(/md=|/maxdepth=)(\d*)", "$1$level"); }
    goto $ab;
It's still necessary to manually activate the Branch view, but it should be possible to bypass it.

Post Reply