query first 'n' identical characters in a foldername
query first 'n' identical characters in a foldername
hi all, is there (in a collection of folders within one parent folder) an easy syntax to query:
show all folders of which the first 5 characters in the foldername are identical?
regards, kazzy
show all folders of which the first 5 characters in the foldername are identical?
regards, kazzy
Re: query first 'n' identical characters in a foldername
left($parent-name:,5)==left($name:,5)
You may also want to limit your name length to >= 5
Otherwise, a length of 1,2,3 or 4 may also match.
len:>=5 left($parent-name:,5)==left($name:,5)
expressions
You may also want to limit your name length to >= 5
Otherwise, a length of 1,2,3 or 4 may also match.
len:>=5 left($parent-name:,5)==left($name:,5)
expressions
Re: query first 'n' identical characters in a foldername
hello David, thanks a lot for your kind reply and code. I tried the query, but it did not yet do what I am looking for. This must be due to my explanation probably .
Please see the foldertree zipped in the attachment, it contains only totally empty folders/subfolders.
When I run the query with 'testtree' selected in my left pane, I aim to get results containing folders starting with 'A' 'H' 'I' 'J' and 'X'. The folders with those names are longer than 5 characters and the first 5 of their respective names are identical. I do not want to be shown any subfolder.
I just wanna express gratitude for your loyal support, any response is not taken for granted. Thanks a lot! Regards, kazzy
Please see the foldertree zipped in the attachment, it contains only totally empty folders/subfolders.
When I run the query with 'testtree' selected in my left pane, I aim to get results containing folders starting with 'A' 'H' 'I' 'J' and 'X'. The folders with those names are longer than 5 characters and the first 5 of their respective names are identical. I do not want to be shown any subfolder.
I just wanna express gratitude for your loyal support, any response is not taken for granted. Thanks a lot! Regards, kazzy
- Attachments
-
- Testtree.zip
- (4.94 KiB) Downloaded 254 times
Re: query first 'n' identical characters in a foldername
Lot clearer now, but not entirely ...
When you want A..12345678 and A..12876543 to be considered "equal", but not B..12345678:
(this is your actual request, but I suspect you're after the following:)
When you want A..12345678 , B..12345678 and A..12345876 to be considered equal, but not A..12876543 :
The following might work too. Will show "equal" folders grouped (I think; untested)
respectively
When you want A..12345678 and A..12876543 to be considered "equal", but not B..12345678:
Code: Select all
"C:\your\starting folder\" folder:regex:"^(.{5})" startwith:sibling-folder:$1: sort:path
When you want A..12345678 , B..12345678 and A..12345876 to be considered equal, but not A..12876543 :
Code: Select all
"C:\your\starting folder\" folder:regex:"^[a-z]\.\.(.{5})" regex:sibling-folder:^[a-z]\.\.$1: sort:path
The following might work too. Will show "equal" folders grouped (I think; untested)
Code: Select all
regex:"^(.{5})" dupe:path;regmatch1
Code: Select all
regex:"^[a-z]\.\.(.{5})" dupe:path;regmatch1
Re: query first 'n' identical characters in a foldername
I don't think any of them are doing it (with most not returning results).
I was thinking (& not that I'm good with this) of something like, dupe:left($name:,5), but that too is incorrect.
I was thinking (& not that I'm good with this) of something like, dupe:left($name:,5), but that too is incorrect.
Re: query first 'n' identical characters in a foldername
Did you test with the files provided by @kazzybash in testtree.zip?
EDIT: made a typo: a "z" fell off. ( [a-] instead of [a-z] ) Please try again.
(thanks for testing, btw!)
EDIT: made a typo: a "z" fell off. ( [a-] instead of [a-z] ) Please try again.
(thanks for testing, btw!)
Re: query first 'n' identical characters in a foldername
Oh, I had PATH: enabled (which I typically do), so that skewed my results, so yes, you've got it.
With,
folder:regex:"^[a-z]\.\.(.{5})" regex:sibling-folder:^[a-z]\.\.$1: sort:path
that still returns (for example) B..0499965078 (which I don't think he wants)
With,
regex:"^[a-z]\.\.(.{5})" dupe:path;regmatch1
that skipped over the "dots" (..), so returns unwanted (though accurate per the query) results
Pretty sure,
folder:regex:"^(.{5})" startwith:sibling-folder:$1: sort:path
regex:"^(.{5})" dupe:path;regmatch1
does it, A H I J X (is that what is said above?)
With this version,
regex:"^(.{5})" dupe:path;regmatch1
and with, dupe_lines=1 (enabled in Preferences), that adds "lines" between the dup'd set, making it nicer to view (for me at least)
With,
folder:regex:"^[a-z]\.\.(.{5})" regex:sibling-folder:^[a-z]\.\.$1: sort:path
that still returns (for example) B..0499965078 (which I don't think he wants)
With,
regex:"^[a-z]\.\.(.{5})" dupe:path;regmatch1
that skipped over the "dots" (..), so returns unwanted (though accurate per the query) results
Pretty sure,
folder:regex:"^(.{5})" startwith:sibling-folder:$1: sort:path
regex:"^(.{5})" dupe:path;regmatch1
does it, A H I J X (is that what is said above?)
With this version,
regex:"^(.{5})" dupe:path;regmatch1
and with, dupe_lines=1 (enabled in Preferences), that adds "lines" between the dup'd set, making it nicer to view (for me at least)
Re: query first 'n' identical characters in a foldername
There is a C..0499965078.3 folder, so I would expect B.. to be included
(the second variation "ignores" the letter-dot-dot part at the beginning and focuses on the first 5 numbers after that to decide which foilders are "equal" )
Re: query first 'n' identical characters in a foldername
Hi NotNull, therube,
this one below does it, that is what I was looking for (not the variant with "B.." being skipped, although I do understand where you're coming from).
regex:"^(.{5})" dupe:path;regmatch1
and with, dupe_lines=1 (enabled in Preferences), that adds "lines" between the dup'd set, making it nicer to view (for me at least)
Thanks a LOT!!
Regards, Kazzy
this one below does it, that is what I was looking for (not the variant with "B.." being skipped, although I do understand where you're coming from).
Then this one is a refinement and, @therube, indeed the lines make it nicer! :NotNull wrote: ↑Wed Mar 20, 2024 6:21 pm When you want A..12345678 and A..12876543 to be considered "equal", but not B..12345678:(this is your actual request...)Code: Select all
"C:\your\starting folder\" folder:regex:"^(.{5})" startwith:sibling-folder:$1: sort:path
regex:"^(.{5})" dupe:path;regmatch1
and with, dupe_lines=1 (enabled in Preferences), that adds "lines" between the dup'd set, making it nicer to view (for me at least)
Thanks a LOT!!
Regards, Kazzy
Re: query first 'n' identical characters in a foldername
hi, the regex works very well, a big thanks once more!
A follow up on this thread. The expression below (and above) is giving me: "the first 5 characters must be identical"
regex:"^(.{5})" dupe:path;regmatch1
Would the following be possible and if so, how: "the first 5 characters must be identical" BUT "if first 3 are "00 " then start counting at character position 4"
What I am aiming at is that those two folders (or files, doesn't matter) show up in the results:
00 Software
Software
or
00.SnazzyDinDin
Snazzy
You get the deal I guess. Thanks a lot in advance, Kazzy
A follow up on this thread. The expression below (and above) is giving me: "the first 5 characters must be identical"
regex:"^(.{5})" dupe:path;regmatch1
Would the following be possible and if so, how: "the first 5 characters must be identical" BUT "if first 3 are "00 " then start counting at character position 4"
What I am aiming at is that those two folders (or files, doesn't matter) show up in the results:
00 Software
Software
or
00.SnazzyDinDin
Snazzy
You get the deal I guess. Thanks a lot in advance, Kazzy
Re: query first 'n' identical characters in a foldername
Please try the following:
regex:^(?:00\s)?(.{5}) dupe:path;regmatch1
(?:...) = group and disable capture.
\s = match a space.
? = only match preceding element if it exists.
regex:^(?:00\s)?(.{5}) dupe:path;regmatch1
(?:...) = group and disable capture.
\s = match a space.
? = only match preceding element if it exists.
Re: query first 'n' identical characters in a foldername
Hello void, thanks a lot for your reply (3 months ago ), I haven't been around for a while and never noticed you replied apparently. Just tried your suggestion/solution and it works like a charm! Kind regards, kazzy
Re: query first 'n' identical characters in a foldername
As said this query works exactly how it should, great (and more than I could ask for).
Maybe it is too theoretical a question, but how come the 'sorting process' follows path? Put differently: how come 'first 'n' identical characters in a foldername' cannot identify across several (two or more) folders?
Kind regards, Kazzy
Maybe it is too theoretical a question, but how come the 'sorting process' follows path? Put differently: how come 'first 'n' identical characters in a foldername' cannot identify across several (two or more) folders?
Kind regards, Kazzy
Re: query first 'n' identical characters in a foldername
Everything sorts by path + regmatch1
This sort is done to find your duplicates
Change the sort order with the sort: search function.
Use the following if you don't want to match files in the same location:
regex:^(?:00\s)?(.{5}) dupe:regmatch1
This sort is done to find your duplicates
Change the sort order with the sort: search function.
Use the following if you don't want to match files in the same location:
regex:^(?:00\s)?(.{5}) dupe:regmatch1
Re: query first 'n' identical characters in a foldername
thank you David!!