Searching for files of a particular length

English support forum

Moderators: white, sheep, Hacker, Stefan2

Post Reply
Andante
Junior Member
Junior Member
Posts: 36
Joined: 2018-01-31, 01:38 UTC

Searching for files of a particular length

Post by *Andante » 2018-10-07, 01:02 UTC

I want to find all files in a large directory whose names are greater than ten characters.

You'd think that this would work: ???????????*.*

But for some unknown reason, every file is returned. Huh? Why?

And what should I use instead?

User avatar
ts4242
Power Member
Power Member
Posts: 1976
Joined: 2004-02-02, 20:08 UTC
Contact:

Re: Searching for files of a particular length

Post by *ts4242 » 2018-10-07, 02:03 UTC

Check ☑ Regex option and search for

Code: Select all

.{11,}\.

Author of Ultra TC Editors
Please support 🌹

Andante
Junior Member
Junior Member
Posts: 36
Joined: 2018-01-31, 01:38 UTC

Re: Searching for files of a particular length

Post by *Andante » 2018-10-08, 05:11 UTC

Wonderful, ts4242, that works like a charm.

I just now looked at Help for Regex (a feature I'd never used before), and it was very very hard to follow. Do you happen to know if there's a simpler guide to it somewhere? I'd like to be able to create my own expressions using Regex, now that you've shown it to me.

Thanks!

User avatar
ts4242
Power Member
Power Member
Posts: 1976
Joined: 2004-02-02, 20:08 UTC
Contact:

Re: Searching for files of a particular length

Post by *ts4242 » 2018-10-08, 05:40 UTC

Andante wrote:
2018-10-08, 05:11 UTC
Do you happen to know if there's a simpler guide to it somewhere?
There are many guides and tutorials out there, i suggest you start with https://regexone.com/

Author of Ultra TC Editors
Please support 🌹

User avatar
Dalai
Power Member
Power Member
Posts: 6272
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Searching for files of a particular length

Post by *Dalai » 2018-10-08, 13:01 UTC

It can also be done without regex, e.g. with a plugin like Filename_ChrCount in conjunction with a rule like this:

Code: Select all

Plugin:           | Property:           |OP:| Value:
filename_chrcount | Filename (Chrcount) | > | 10
on the Plugins tab in TC's search.

To do so: install the plugin (double-click, Enter), then open TC's search, switch to Plugins tab and set the values to the above.

HTH

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

Andante
Junior Member
Junior Member
Posts: 36
Joined: 2018-01-31, 01:38 UTC

Re: Searching for files of a particular length

Post by *Andante » 2018-10-09, 23:17 UTC

*Great* tutorial, ts4242, thanks. Have been studying it.

So tell me. Is there any difference between these two?
(a|b|c)
[abc]

User avatar
obeg
Junior Member
Junior Member
Posts: 25
Joined: 2006-09-28, 09:20 UTC
Location: Sweden

Re: Searching for files of a particular length

Post by *obeg » 2018-10-10, 11:48 UTC

There is no difference when it comes to matching, they will produce the same results.

But the first one will remember the match and it is possible to use in a replace.

If you want to look at from a textual description it is
a OR b OR c
one of the following, a or b or c

User avatar
Stefan2
Power Member
Power Member
Posts: 2175
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Searching for files of a particular length

Post by *Stefan2 » 2018-10-10, 12:28 UTC

The difference comes with other than such simple examples:

(abc|def|ghi) > match on 'abc' or 'def' or...
[abcdefghi] same as [a-i] >> match on any of that 'a' or 'b' or...


And (||) groups the query:
ab|c|d >>> match 'ab' or 'c' or...
a(b|c|d) >>> match 'ab' or 'ac' or..


 

Andante
Junior Member
Junior Member
Posts: 36
Joined: 2018-01-31, 01:38 UTC

Re: Searching for files of a particular length

Post by *Andante » 2018-10-10, 19:21 UTC

Thanks to everyone for this! I've been studying Regex the past couple of days, and feel like I'm starting to get a handle on it.

Currently, my only place to use it is in TC, but since I'm using that daily, I'll get practice with Regex for sure.

I'm curious why \w includes underscore but no other punctuation mark. There must be some reason for that anomaly!

Post Reply