Branch view, copy indents to clipboard?
Branch view, copy indents to clipboard?
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.
Eg., then you can paste entire multiple directory structures into MS Word and apply multilevel numbering which is useful for an index.
-
- Site Admin
- Posts: 60635
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Branch view, copy indents to clipboard?
This report feature does something similar:
- Attachments
-
- 2023-11-13_092805.png (8.58 KiB) Viewed 767 times
FAQ | XY News RSS | XY Twitter
Re: Branch view, copy indents to clipboard?
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
Re: Branch view, copy indents to clipboard?
Thank you!
Re: Branch view, copy indents to clipboard?
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)
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)
Re: Branch view, copy indents to clipboard?
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
Re: Branch view, copy indents to clipboard?
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)).*$", "");
Re: Branch view, copy indents to clipboard?
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
Re: Branch view, copy indents to clipboard?
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 wrote: ↑12 Feb 2024 23:40Code: 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.]+?; .+?$");
Re: Branch view, copy indents to clipboard?
Did you post sample data to see if those patterns would apply? Nope, you didn't
I was just fixing your errors
I was just fixing your errors
One of my scripts helped you out? Please donate via Paypal
Re: Branch view, copy indents to clipboard?
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>
Re: Branch view, copy indents to clipboard?
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
Re: Branch view, copy indents to clipboard?
You are right...thank you for fixing my mistake, it's been a long day. What you have up there outputs perfectly!!! THANKS! :-)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;