Regular expressions for filename searches & file sorting

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

User avatar
JamieG
Member
Member
Posts: 47
Joined: 2004 Oct 03, 11:43
Location: Paris, France

Regular expressions for filename searches & file sorting

Post by JamieG »

Hi Nikos, FG & everybody,

If ever you have a lazy few weeks and are wondering what marvelous new feature might bring joy and happiness to at least one user, the following two items have been at the top of my wish list for years now.

1)  Finding a list of files using a RE on the filename

A checkbox "RE" for the input box "Named:" on the "Find files or folders" window (<ctrl/F>).

2)  Sorting files based on a RE-selected part of the filename

I'm not sure where one would put this in X2's interface, but I'd love to be shown a list of files or folders in an order determined by a portion of the filename.  For example, I've got several hundred directories of photos collected and organized by the family.  Taking a subset, their lexical order is:

Avoriez-Helen&Jamie Jan 1976
Biaritz 1998
Brittany trip Jun 1992
English canals Sep 1993
Dome Vermont 1971
Helen-Scott wedding Jun 1991
Hillside landscapes 2003
Hillside landscapes, 1979
Hillside, Helen Nov 1981
Oregon 1987

If I could specify a sorting RE of "\b\d{4}\b" (with whatever parentheses might be required by Windows' RegEx facility for returning the matching substring), X2 could show me the this list in chronological order.

Dome Vermont 1971
Avoriez-Helen&Jamie Jan 1976
  ...
Biaritz 1998
Hillside landscapes 2003

I could rename 'em all (& probably will to give the collection a bit more structure), but the same facility would then become useful if I wanted to view the list in or order of the locale or the people.

Et voilà.  Wish list réactualisée.  Hoping everybody is well & with best regards, Jamie
User avatar
Alec_Burgess
Member
Member
Posts: 13
Joined: 2006 Oct 20, 03:09

Regex for rename too?

Post by Alec_Burgess »

1)  Finding a list of files using a RE on the filename

A checkbox "RE" for the input box "Named:" on the "Find files or folders" window (<ctrl/F>).

2)  Sorting files based on a RE-selected part of the filename
I wasn't sure whether the BULK-rename facility could use regex FIND and REPLACE in constructing the proposed new name.

I searched through the PDF manual and found description of regex syntax in an Appendix but conspicuously absent is any mention of using these for either FIND/FILTER or RENAME.

Am I correct that this is the current state of play?
Any chance it's already on the to-do list?
Failing that I'll go find theRename  :(

I asked because I'm temporarily working on a new computer that has none of the tools I'm used to working with. One of the first I d/l'd was Xplorer and was hoping to avoid getting a separate renaming program.
Regards .. Alec
User avatar
nikos
Site Admin
Site Admin
Posts: 15800
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

the regex part in xplorer2 is only for searching for text in files
User avatar
Thracx
Silver Member
Silver Member
Posts: 263
Joined: 2004 Nov 05, 19:33
Contact:

Re: Regular expressions for filename searches..

Post by Thracx »

JamieG wrote:...
1)  Finding a list of files using a RE on the filename
...
*bump*

Sorry to do that, but I would really like this feature and it doesn't sound too difficult to implement (since RegEx functionality already exists when matching on the contents of files).


I will say that I never thought about JamieG's second feature request, but it certainly would be neat and I'd probably use it if it did happen to come into existence.
-Thracx

"Man wants to know, and when he ceases to do so, he is no longer a man."
-Fridtjof Nansen
User avatar
nikos
Site Admin
Site Admin
Posts: 15800
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

if i was to add this, then all the 000s places where filename wildcards are accepted would have to be changed so that there's a checkbox for "regular expression", messing up the gui for probably just you and the other 2 guys in this thread :)
User avatar
Thracx
Silver Member
Silver Member
Posts: 263
Joined: 2004 Nov 05, 19:33
Contact:

Post by Thracx »

nikos wrote:if i was to add this, then all the 000s places where filename wildcards are accepted would have to be changed so that there's a checkbox for "regular expression", messing up the gui for probably just you and the other 2 guys in this thread :)
Then how about one of those fancy 'registry only tweaks' that function as a global checkbox?

That way the 2 of us can turn it on and always use RegEx, and everyone else just lives on like normal ;-)
-Thracx

"Man wants to know, and when he ceases to do so, he is no longer a man."
-Fridtjof Nansen
User avatar
mmelo
Member
Member
Posts: 45
Joined: 2009 Jul 14, 23:45
Location: Lisbon, Portugal

Post by mmelo »

I concur with what the other guys are saying... there are times when regexps on the filenames are welcome. Say that I want to look for pictures from my camera (which are always in the format DSC_<number>.JPG)... with DSC_\d+\.JPG I would be sorted, without having to add a couple of wonky rules.
Baard
New Member
Posts: 1
Joined: 2009 Jul 15, 19:48

Post by Baard »

nikos wrote:... you and the other 2 guys in this thread :)
Make that three :)

Decent regular expression support (especially in renaming) is a major feature for me. I almost chose a competitor due to this (but due to the restrictive license I ended up with x2).

In a tool such as this, aiming at an audience that seek more advanced features, this should not be considered a bloat function or unnecessary clutter.

Otherwise I find x2 an excellent tool and a true time saver. :)

/Bard
User avatar
nikos
Site Admin
Site Admin
Posts: 15800
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

can some RE master give me a small example RE that is actually a syntax error?
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

Apparently this is a boo-boo.  RegEx is hard enough to get right, never mind wrong. :shrug:  (And how many things can you say that about? :D)
User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1241
Joined: 2005 Oct 16, 19:09

Post by FrizzleFry »

http://www.regular-expressions.info/freespacing.html
Likewise, grouping modifiers cannot be broken up. (?>atomic) is the same as (?> ato mic ) and as ( ?>ato mic). They all match the same atomic group. They're not the same as (? >atomic). In fact, the latter will cause a syntax error. The ?> grouping modifier is a single element in the regex syntax, and must stay together. This is true for all such constructs, including lookaround, named groups, etc.
User avatar
nikos
Site Admin
Site Admin
Posts: 15800
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

this one then Chrome\/[3-15]
User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1241
Joined: 2005 Oct 16, 19:09

Post by FrizzleFry »

Keep in mind that something like:
[1-35]
is valid, it matches 1,2,3,5

It is the 3-1 range that is invalid.
Last edited by FrizzleFry on 2012 Jan 31, 19:56, edited 1 time in total.
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

FrizzleFry wrote:Keep in mind that something like [1-35] is valid (1,2,3,5) - It is the 3-1 range that is invalid.
It is?  I thought it was a character-class range problem (as in single-characters) - which is why the solution of "[3-9]|1[0-5]" (or "[0-9]{1,2}" for double-digits) was the correct conclusion?  (RegEx makes my head hurt every time I think about playing with it.)
User avatar
nikos
Site Admin
Site Admin
Posts: 15800
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

i was never a fan of non-deterministic finite state machines either :)
Post Reply