I have two rather equal folder structures. $a is located in D:\Temp and $b in E:\Temp.
I removed the leading paths for this example to make it a bit easier to read / understand.
Comparing them and getting only those folders that do exist only in $a is rather easy. It's basically a formatlist with an inverted filter containing $b.$a = <<<>>>
a
b
b\c
b\c\d
b\e
b\e\f
b\e\g
c
>>>;
$b = <<<>>>
a
b
c
>>>;
E.g.:
$aStripped = formatlist($a, "f", "<crlf>", "!$b");
This results in:
So far that's fine. But I want this list stripped down further by removing all subdirectories that are nested deeper than the new base ("b") + 1.b\c
b\c\d
b\e
b\e\f
b\e\g
E.g.
b\c is already unique (it didn't exist in $b)
So:
b\c\d
should be removed
b\e is already unique (it didn't exist in $b)
So:
b\e\f
b\e\g
should be removed
My idea:
Code: Select all
$aStripped = formatlist($a, "f", "<crlf>", "!$b");
foreach($line, $aStripped, "<crlf>") {
$pattern = regexreplace($line, "(\\|\^|\$|\.|\+|\(|\)|\[|\]|\{|\})", "\$1");
$match = regexmatches($aStripped, $pattern);
if (gettoken($match, "count", "|") > 1) { continue; }
else { $aStripped = regexreplace($aStripped, "^$pattern$"); }
}
text formatlist($aStripped, "ens", "<crlf>");
XYplorer Beta Club