Page 1 of 1

Branch View - How to set folder depth

Posted: 02 Feb 2016 05:54
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? :?:

Re: Branch View - How to set folder depth

Posted: 02 Feb 2016 09:08
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;

Re: Branch View - How to set folder depth

Posted: 02 Feb 2016 15:10
by jaywalker32
Excellent! That's exactly it. Thanks!

Re: Branch View - How to set folder depth

Posted: 08 Feb 2016 11:11
by davidp
Suppose i want to see up to 3 levels of folder depth,what command should i use.

Re: Branch View - How to set folder depth

Posted: 08 Feb 2016 11:43
by highend
md=n -> maxdepth, n = levels to show

Re: Branch View - How to set folder depth

Posted: 08 Feb 2016 12:15
by davidp
"Extend it to:
/md=0:flat

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

where is n there in the command

Re: Branch View - How to set folder depth

Posted: 08 Feb 2016 12:20
by highend
There is already an example in the script...

Code: Select all

"0 = No recursion<crlf>1 = One level deep<crlf>..."

Re: Branch View - How to set folder depth

Posted: 12 Oct 2024 19:22
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.