Page 1 of 1
Branch view, copy indents to clipboard?
Posted: 13 Nov 2023 03:57
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.
Re: Branch view, copy indents to clipboard?
Posted: 13 Nov 2023 09:30
by admin
This report feature does something similar:
Re: Branch view, copy indents to clipboard?
Posted: 13 Nov 2023 10:05
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;
Re: Branch view, copy indents to clipboard?
Posted: 05 Dec 2023 03:55
by PlorerXY6
Thank you!
Re: Branch view, copy indents to clipboard?
Posted: 14 Dec 2023 15:44
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)
Re: Branch view, copy indents to clipboard?
Posted: 14 Dec 2023 18:54
by highend
I've given you the basics to process the raw data. Now add the necessary regexes to get the output you need?
Re: Branch view, copy indents to clipboard?
Posted: 12 Feb 2024 22:33
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)).*$", "");
Re: Branch view, copy indents to clipboard?
Posted: 12 Feb 2024 23:40
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.]+?; .+?$");
Re: Branch view, copy indents to clipboard?
Posted: 13 Feb 2024 00:13
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.
Re: Branch view, copy indents to clipboard?
Posted: 13 Feb 2024 00:17
by highend
Did you post sample data to see if those patterns would apply? Nope, you didn't
I was just fixing your errors
Re: Branch view, copy indents to clipboard?
Posted: 13 Feb 2024 21:46
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>
Re: Branch view, copy indents to clipboard?
Posted: 13 Feb 2024 23:11
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;
Re: Branch view, copy indents to clipboard?
Posted: 13 Feb 2024 23:41
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! :-)
Re: Branch view, copy indents to clipboard?
Posted: 05 Jun 2024 22:31
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;
Is there a way to get it to sort each folder in the tree by date modified order first (keep tree structure) and then strip everything out?
Re: Branch view, copy indents to clipboard?
Posted: 05 Jun 2024 23:27
by highend
With enough effort? Sure