Page 1 of 1
Selecting items with double spaces - how?
Posted: 26 Jul 2015 03:50
by Papoulka
In scripting I'm trying to select all list pane items that have two spaces / blanks in their name. For example in the following list (where 'b' stands for a space):
- DATAb1.txt
DATAbb2.txt
DATAb3.txt
I want only the file "DATAbb2.txt" to be selected.
However, neither of these work:
The first selects no files; the second selects all files.
So I have two questions. (1) how can I do this and (2) shouldn't selfilter (at least) achieve this i.e. is there a bug?
Re: Selecting items with double spaces - how?
Posted: 26 Jul 2015 04:42
by SkyFrontier
Selection filter (default: ctrl+m):
(it's a regex selection)
Re: Selecting items with double spaces - how?
Posted: 26 Jul 2015 05:14
by Papoulka
But I want to do this in a script and then operate on those selected items. In the Help, at least, neither SEL, SELECTITEMS, nor SELFILTER have any regex option. So where would I use your pattern? Is this done in SELFILTER?
Thanks for any help.
And I still wonder: shouldn't SELFILTER "bb" do what I want? If not, why not i.e. how would I know this shouldn't work?
Re: Selecting items with double spaces - how?
Posted: 26 Jul 2015 08:12
by bdeshi
Code: Select all
selfilter "* *"; //selects two-consecutive-spaces-in-name items
text get('SelectedItemsPathNames', <crlf>); //an operation on selected items, lists all of them
<edit>
btw, only selfilter can select multiple items by pattern.
sel selects ONE item and optionally a number of CONSECUTIVE items before or after,
and selectitems selects by |-separated FULL names or paths.
</edit>
Re: Selecting items with double spaces - how?
Posted: 26 Jul 2015 10:38
by SkyFrontier
Or this?
Code: Select all
$a = <<<#
c:\test\soft\xy\_Titlebar Template_02.txt
c:\test\soft\xy\_TitlebarTemplate_ _01.txt
c:\test\soft\xy\_TitlebarTemplate_ 01.txt
c:\test\soft\xy\_TitlebarTemplate.txt
#;
$b = regexmatches("$a", "^.*?\b( {2,})\b.*$", "<crlf>");
text $b;
'$a' can be filled by using get(selecteditemspathnames), alternatively (more in line with what I guess is what you want). Or a (recursive?) folderreport().
Re: Selecting items with double spaces - how?
Posted: 26 Jul 2015 10:56
by highend
To use a precise match (it won't output entries with more than two spaces in a row):
Code: Select all
$b = regexmatches($a, "^.*?\b {2}\b.*$", "<crlf>");
Re: Selecting items with double spaces - how?
Posted: 26 Jul 2015 20:12
by Papoulka
Sammay - thank you for showing
I would never have figured this out from the Help on selfilter.
Is there a further reference on patterns like this that I'm missing?
SkyFrontier & Highend - thanks for the info.
Can you tell me how to in general select list pane files using a regex? I'm sure this can be done but can't think of any direct way.
Re: Selecting items with double spaces - how?
Posted: 26 Jul 2015 20:32
by admin
I see this (first post) as a bug. Fix comes.
Re: Selecting items with double spaces - how?
Posted: 26 Jul 2015 21:26
by highend
Can you tell me how to in general select list pane files using a regex?
There is no direct way to do this. You have to use e.g. listfolder() and a regexmatch() afterwards.