RegEx in Search and multi rename: where is the "NOT" operator?

English support forum

Moderators: sheep, Hacker, Stefan2, white

Post Reply
Christo
Junior Member
Junior Member
Posts: 4
Joined: 2014-10-25, 11:30 UTC

RegEx in Search and multi rename: where is the "NOT" operator?

Post by *Christo » 2019-12-01, 09:04 UTC

Hi , I need some help with a regular expression please.

I use regular expressions regularly but i have not been able to find the "NOT" operator.

I need to do a file search to find filenames not containing a certain word or text. I sometimes need this in multi renaming in the search field too.

example
so instead of searching for all files containing [eng] I would just like all files not containing [eng].

Thanks in advance.

Christo
Junior Member
Junior Member
Posts: 4
Joined: 2014-10-25, 11:30 UTC

Re: Need help with RegEx in Filesearch and multi rename.

Post by *Christo » 2019-12-01, 09:26 UTC

I seemed to have come right without using regex with this command *|*[eng].* but i would still like the regex version.

NotNull
Junior Member
Junior Member
Posts: 22
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: Need help with RegEx in Filesearch and multi rename.

Post by *NotNull » 2019-12-01, 15:26 UTC

Total Commande uses the TRegExpr library to handle regular expressions.
This library does not support the lookaround functions that are needed for your case.


However ...
  • If you have Everything installed and enabled (check the 'Everything' box in the search dialog), you can use Everything's regular expression library (PCRE) to search for
    ed: regex:^(?!=.*" a certain word or text")
    ed: regex:^(?!.*" a certain word or text")
    or without using regex: !" a certain word or text"
    (PCRE does support lookaround functions)
  • In the TC search dialog is a "Plugin" tab where you can specify the !contains operator
  • If the position of " a certain word or text" is fixed on - let's say - position 5, you can use ^.{4}[^c][^o][^n][^t][^a][^i][^n] (and the rest of your string). Not very practical; I just mention it.
Note that TRegExpr as well as Everything's implementation of PCRE are case insensitive.
Last edited by NotNull on 2019-12-01, 23:16 UTC, edited 1 time in total.

User avatar
tuska
Power Member
Power Member
Posts: 1755
Joined: 2007-05-21, 12:17 UTC

Re: Need help with RegEx in Filesearch and multi rename.

Post by *tuska » 2019-12-01, 18:35 UTC

NotNull wrote:
2019-12-01, 15:26 UTC
ed: regex:^(?!=.*" a certain word or text")
I tested this solution out of interest (each with file ab.txt + 1 file ... [eng] ...):

Code: Select all

ed:files:regex:^(?!=.*"[eng]")
does not work for me with the following files in a folder:

Code: Select all

ab.txt, a[eng]a.txt, [eng].txt, a[eng].txt, [eng]a.txt
That an ab.txt file also found in the folder is also displayed with this query.
regular expressions 101 brings 2 matches instead of 1 match.

Can you please check again?
Thank you!

NotNull
Junior Member
Junior Member
Posts: 22
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *NotNull » 2019-12-01, 19:59 UTC

Try it with:

Code: Select all

ed:  files:   regex:^(?!.*"\[eng\]")
That is: remove the "=" and escape the special chars "[" and "]" with a "\"
[ and ] are meta characters that you will need to escape. If not, it will search for names without an e, n or g , matching your ab.txt.


EDIT:
Oh, now I see it .. I am the one that posted the syntax with the "=" included.
The ?= is for positive lookaheads; ?! for negative lookaheads. No idea how I got those two mixed up. Sorry ...

User avatar
tuska
Power Member
Power Member
Posts: 1755
Joined: 2007-05-21, 12:17 UTC

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *tuska » 2019-12-01, 21:46 UTC

NotNull wrote:
2019-12-01, 19:59 UTC
Try it with:

Code: Select all

ed:  files:   regex:^(?!.*"\[eng\]")
This solution works! :)
Thank you for your explanations and endeavours!

In summary, these solutions are available (with the exception of .. "position 5" ..):
Example: Folder [eng], Files: ab.txt, a[eng]a.txt, [eng].txt, a[eng].txt, [eng]a.txt

Code: Select all

Total Commander
! --------------------------------- ! --------------------------------- !
! WITHOUT RegEx		            ! WITH RegEx			!
! --------------------------------- ! --------------------------------- !
! *.* |*[eng]*		            !      ---			        !
! Folders are also displayed        !				        !
! --------------------------------- ! --------------------------------- !
! WITHOUT RegEx                                                         !
! ALT+SHIFT+F7, Search in: Path, Plugins-Tab: [x] Search in plugins     !
! Plugin: tc | Property: fullname | OP: !contains | Value: [eng]        !
! Folders are also displayed                                            !
! --------------------------------- ! --------------------------------- !

Code: Select all

Total Commander + 'Everything'
! --------------------------------- ! --------------------------------- !
! WITHOUT RegEx		            ! WITH RegEx			!
! --------------------------------- ! --------------------------------- !
! ed:files: !"[eng]"	            ! ed:files:regex:^(?!.*"\[eng\]")   !
! Only files are displayed          ! Only files are displayed          !
! --------------------------------- ! --------------------------------- !

Windows 10 Pro (x64) Version 1909 (OS build 18363.476)
TC 9.50ß7 x64/x86 | Everything - Version 1.4.1.958 (x64)
☑ 'Everything' | Search queries: TC <=> 'Everything'

NotNull
Junior Member
Junior Member
Posts: 22
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *NotNull » 2019-12-01, 23:07 UTC

tuska wrote:
2019-12-01, 21:46 UTC
In summary, these solutions are available (with the exception of .. "position 5" ..):
Example: Folder [eng], Files: ab.txt, a[eng]a.txt, [eng].txt, a[eng].txt, [eng]a.txt
I guess (not tested) that positional searching should be possible by using the ? wilcard (symbolizing one single character):

?[eng]* should find only a[eng]a.txt and a[eng].txt

User avatar
tuska
Power Member
Power Member
Posts: 1755
Joined: 2007-05-21, 12:17 UTC

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *tuska » 2019-12-02, 11:33 UTC

NotNull wrote:
2019-12-01, 23:07 UTC
tuska wrote:
2019-12-01, 21:46 UTC
In summary, these solutions are available (with the exception of .. "position 5" ..):
Example: Folder [eng], Files: ab.txt, a[eng]a.txt, [eng].txt, a[eng].txt, [eng]a.txt
I guess (not tested) that positional searching should be possible
by using the ? wildcard (symbolizing one single character):
?[eng]* should find only a[eng]a.txt and a[eng].txt
Yes, this solution works too:

Code: Select all

ALT+SHIFT+F7, Search for: ?[eng]*
In the solutions offered by you so far, I think a solution for Christo should have been there.
For me, the tests are therefore complete.

Thank you!

User avatar
tuska
Power Member
Power Member
Posts: 1755
Joined: 2007-05-21, 12:17 UTC

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *tuska » 2019-12-02, 16:10 UTC

Another solution TC (without RegEx):

Search for: *.* |*.        --> finds only files (no folders!)
[x] F2 Search in found files
Search for: *.* |*[eng]*

User avatar
petermad
Power Member
Power Member
Posts: 8967
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *petermad » 2019-12-03, 02:10 UTC

Search for: *.* |*. --> finds only files (no folders!)
This assumes that you don't have and periods in foldernames.
License #524 (1994)
Danish Total Commander Translator
TC 9.5b8 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1909) 64bit, 'Everything' 1.4.1.935 (x64)
TC 3.0b12 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

User avatar
tuska
Power Member
Power Member
Posts: 1755
Joined: 2007-05-21, 12:17 UTC

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *tuska » 2019-12-03, 12:49 UTC

2petermad
Thanks for the hint!

Unfortunately I don't know any other solution to find only files in a search with TC, *)
and thus excludes the folders from the search result.
--------------------------------------------------
Interestingly enough, I can set this filter (menu "Show" - "Custom...":

Code: Select all

*.* | *.*\
and with this the folders are excluded.

The following search with:

Code: Select all

*.* |*[eng]*
will display non-relevant folders again.

*) EDIT:
Of course this is possible with a search with plugin:
ALT+SHIFT+F7, Plugins-Tab, [x] Search in plugins,
Plugin: tc | Property: file type | OP: = | Value: file -> Start search
... [x] F2 Search in found files, General-Tab: Search for: *.* |*[eng]* ... done!

NotNull
Junior Member
Junior Member
Posts: 22
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *NotNull » 2019-12-03, 13:44 UTC

Almost too obvious to mention:

.. or limit the search to files/foders that don't have the Directory attribute set ( Advanced tab)

But let's hear what @Christo has to say about all this first ...

User avatar
petermad
Power Member
Power Member
Posts: 8967
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *petermad » 2019-12-03, 19:47 UTC

Unfortunately I don't know any other solution to find only files in a search with TC,
"Find Files" -> "Advanced" (tab) -> mark "Attributes" - > unmark "Directory"
License #524 (1994)
Danish Total Commander Translator
TC 9.5b8 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1909) 64bit, 'Everything' 1.4.1.935 (x64)
TC 3.0b12 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

NotNull
Junior Member
Junior Member
Posts: 22
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *NotNull » 2019-12-04, 17:04 UTC

I bet @tuska is intelligent enough to have understood that the first time ..

(still no sign of @Christo ...)

User avatar
tuska
Power Member
Power Member
Posts: 1755
Joined: 2007-05-21, 12:17 UTC

Re: RegEx in Search and multi rename: where is the "NOT" operator?

Post by *tuska » 2019-12-04, 17:29 UTC

NotNull wrote:
2019-12-04, 17:04 UTC
I bet @tuska is intelligent enough to have understood that the first time ..
Bet won! :)
I think, petermad just wanted to make sure this understandable for Christo.

On this subject I first expressed myself misleadingly, i.e. I actually meant,
I don't know how to exclude folders, if you enter a search term only in the field "Search for:".
(See also my note regarding filters).

After I realized that this can also be misunderstood, I quickly added a search variant under "EDIT".

Post Reply