Branch view, copy indents to clipboard?

Features wanted...
Post Reply
PlorerXY6
Posts: 60
Joined: 13 Oct 2022 19:51

Branch view, copy indents to clipboard?

Post by PlorerXY6 »

Is there any script or feature in branch view, to copy folder tab indents to clipboard?
Eg., then you can paste entire multiple directory structures into MS Word and apply multilevel numbering which is useful for an index.

admin
Site Admin
Posts: 60620
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Branch view, copy indents to clipboard?

Post by admin »

This report feature does something similar:
Attachments
2023-11-13_092805.png
2023-11-13_092805.png (8.58 KiB) Viewed 742 times

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

Re: Branch view, copy indents to clipboard?

Post by highend »

You use what Don posted with the button "To Clipboard" and then execute this script afterwards:

Code: Select all

    $indention = "    "; // E.g. 4 spaces

    // Get only folders
    $result = formatlist(<clp>, "f", <crlf>, "*<DIR>*");

    // Remove unnecessary stuff
    $result = regexreplace($result, "; <DIR>;.+?(?=\r?\n|$)");

    // Replace indention
    $result = replace($result, ". ", $indention);

    // Remove leading "\ "
    $result = replace($result, "\ ");

    text $result;
One of my scripts helped you out? Please donate via Paypal

PlorerXY6
Posts: 60
Joined: 13 Oct 2022 19:51

Re: Branch view, copy indents to clipboard?

Post by PlorerXY6 »

Thank you!

PlorerXY6
Posts: 60
Joined: 13 Oct 2022 19:51

Re: Branch view, copy indents to clipboard?

Post by PlorerXY6 »

Is there a way to strip the extra info (extension onwards) from subfiles as well & include tab indents from branch view? Think above script only handles directories.

EDIT: Must have been doing something weird, now it indents everything, but still want to get rid of this stuff:
1. in directories, the ending: -, <DIR>, 2023/12/14 10:15:01
2. file endings including extension: .pdf", 327,935, 2023/12/12 14:17:59
3. All quotation marks
4. Don't replace periods in the file name with spaces--only the periods before the file name start (before the quotations)

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

Re: Branch view, copy indents to clipboard?

Post by highend »

I've given you the basics to process the raw data. Now add the necessary regexes to get the output you need?
One of my scripts helped you out? Please donate via Paypal

PlorerXY6
Posts: 60
Joined: 13 Oct 2022 19:51

Re: Branch view, copy indents to clipboard?

Post by PlorerXY6 »

highend wrote: 14 Dec 2023 18:54 I've given you the basics to process the raw data. Now add the necessary regexes to get the output you need?
I tried doing this with ChatGPT but it keeps erroring out...are you able to assist to fix it at all?

//addition - Remove opening quotes
$result = regexreplace($result, "^\"");

// addition - Remove ending quotes
$result = regexreplace($result, "\"$");

// addition Remove file extension and everything after
$result = regexreplace($result, "(?m)(\\.(pdf|doc|docx|msg|jpg|jpeg)).*$", "");

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

Re: Branch view, copy indents to clipboard?

Post by highend »

Code: Select all

    //addition - Remove opening quotes
    $result = regexreplace($result, "^""");

    // addition - Remove ending quotes
    $result = regexreplace($result, """$");

    // addition Remove file extension and everything after
    $result = regexreplace($result, "\.[^.]+?; [0-9.]+?; .+?$");
One of my scripts helped you out? Please donate via Paypal

PlorerXY6
Posts: 60
Joined: 13 Oct 2022 19:51

Re: Branch view, copy indents to clipboard?

Post by PlorerXY6 »

highend wrote: 12 Feb 2024 23:40

Code: Select all

    //addition - Remove opening quotes
    $result = regexreplace($result, "^""");

    // addition - Remove ending quotes
    $result = regexreplace($result, """$");

    // addition Remove file extension and everything after
    $result = regexreplace($result, "\.[^.]+?; [0-9.]+?; .+?$");
It runs through now without error but doesn't seem to be accomplishing the three tasks above...guess I'll have to try keep figuring out what the codes are to actually remove those items.

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

Re: Branch view, copy indents to clipboard?

Post by highend »

Did you post sample data to see if those patterns would apply? Nope, you didn't
I was just fixing your errors
One of my scripts helped you out? Please donate via Paypal

PlorerXY6
Posts: 60
Joined: 13 Oct 2022 19:51

Re: Branch view, copy indents to clipboard?

Post by PlorerXY6 »

highend wrote: 13 Feb 2024 00:17 Did you post sample data to see if those patterns would apply? Nope, you didn't
I was just fixing your errors
Thank you, I do appreciate it.

Can you please try these sample data
C:\1\root
. "Schedule ABC.pdf", 62,251, 2022/05/26 10:07:10
. "Schedule DEF.docx", 321,114, 2022/05/26 10:07:10
. Schedule GHI.msg, 1,794,481, 2022/05/26 10:07:12
\ Documents, <DIR>, 2024/02/12 17:58:10


3 files above - 2 have quotations, 1 doesn't, so would like all quotations removed. Then would like remove any of the above-mentioned file extensions and comma/date after ,<DIR>, plus everything after in the line, so I'm ideally left with:
C:\1\root
(spacex4) Schedule ABC.pdf
(spacex4) Schedule DEF.docx
(spacex4) Schedule GHI.msg
Documents <DIR>

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

Re: Branch view, copy indents to clipboard?

Post by highend »

Your expected result doesn't match what you write (removed file extensions?...)

Code: Select all

    $indention = <space 4>; // E.g. 4 spaces

    // Remove leading "\ " for folders
    $result = replace(<clp>, "\ ");

    // Replace unnecessary stuff (folders)
    $result = regexreplace($result, ", <DIR>,.+?(?=\r?\n|$)", " <DIR>");

    // Files
    $result = regexreplace($result, ", [0-9,]+?, [0-9]{4}/.+?(?=\r?\n|$)");

    // Remove all quotation marks
    $result = replace($result, '"');

    // Remove specific file extensions
    $result = regexreplace($result, "(\.(pdf|doc|docx|msg|jpg|jpeg))$");

    // Replace indention
    $newResult = "";
    foreach($item, $result, <crlf>, "e") {
        $cntIndent  = gettoken(regexmatches($item, "^(\. )*"), "count", ". ");
        $prefix     = strrepeat($indention, $cntIndent);
        $newResult .= $prefix. regexreplace($item, "^(\. )*") . <crlf>;
    }
    text $newResult;
One of my scripts helped you out? Please donate via Paypal

PlorerXY6
Posts: 60
Joined: 13 Oct 2022 19:51

Re: Branch view, copy indents to clipboard?

Post by PlorerXY6 »

highend wrote: 13 Feb 2024 23:11 Your expected result doesn't match what you write (removed file extensions?...)

Code: Select all

    $indention = <space 4>; // E.g. 4 spaces

    // Remove leading "\ " for folders
    $result = replace(<clp>, "\ ");

    // Replace unnecessary stuff (folders)
    $result = regexreplace($result, ", <DIR>,.+?(?=\r?\n|$)", " <DIR>");

    // Files
    $result = regexreplace($result, ", [0-9,]+?, [0-9]{4}/.+?(?=\r?\n|$)");

    // Remove all quotation marks
    $result = replace($result, '"');

    // Remove specific file extensions
    $result = regexreplace($result, "(\.(pdf|doc|docx|msg|jpg|jpeg))$");

    // Replace indention
    $newResult = "";
    foreach($item, $result, <crlf>, "e") {
        $cntIndent  = gettoken(regexmatches($item, "^(\. )*"), "count", ". ");
        $prefix     = strrepeat($indention, $cntIndent);
        $newResult .= $prefix. regexreplace($item, "^(\. )*") . <crlf>;
    }
    text $newResult;
You are right...thank you for fixing my mistake, it's been a long day. What you have up there outputs perfectly!!! THANKS! :-)

Post Reply