RegEx in Search and multi rename: where is the "NOT" operator?
Moderators: white, Hacker, petermad, Stefan2
RegEx in Search and multi rename: where is the "NOT" operator?
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.
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.
Re: Need help with RegEx in Filesearch and multi rename.
I seemed to have come right without using regex with this command *|*[eng].* but i would still like the regex version.
Re: Need help with RegEx in Filesearch and multi rename.
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 ...
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.
Last edited by NotNull on 2019-12-01, 23:16 UTC, edited 1 time in total.
Re: Need help with RegEx in Filesearch and multi rename.
I tested this solution out of interest (each with file ab.txt + 1 file ... [eng] ...):
Code: Select all
ed:files:regex:^(?!=.*"[eng]")
Code: Select all
ab.txt, a[eng]a.txt, [eng].txt, a[eng].txt, [eng]a.txt
regular expressions 101 brings 2 matches instead of 1 match.
Can you please check again?
Thank you!
Re: RegEx in Search and multi rename: where is the "NOT" operator?
Try it with:
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 ...
Code: Select all
ed: files: regex:^(?!.*"\[eng\]")
[ 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 ...
Re: RegEx in Search and multi rename: where is the "NOT" operator?
This solution works!NotNull wrote: ↑2019-12-01, 19:59 UTC Try it with:Code: Select all
ed: files: regex:^(?!.*"\[eng\]")
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'
Re: RegEx in Search and multi rename: where is the "NOT" operator?
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
Re: RegEx in Search and multi rename: where is the "NOT" operator?
Yes, this solution works too:
Code: Select all
ALT+SHIFT+F7, Search for: ?[eng]*
For me, the tests are therefore complete.
Thank you!
Re: RegEx in Search and multi rename: where is the "NOT" operator?
Another solution TC (without RegEx):
Search for: *.* |*. --> finds only files (no folders!)
[x] F2 Search in found files
Search for: *.* |*[eng]*
Search for: *.* |*. --> finds only files (no folders!)
[x] F2 Search in found files
Search for: *.* |*[eng]*
Re: RegEx in Search and multi rename: where is the "NOT" operator?
This assumes that you don't have and periods in foldernames.Search for: *.* |*. --> finds only files (no folders!)
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: RegEx in Search and multi rename: where is the "NOT" operator?
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...":
and with this the folders are excluded.
The following search with:
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!
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
*.* | *.*\
The following search with:
Code: Select all
*.* |*[eng]*
*) 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!
Re: RegEx in Search and multi rename: where is the "NOT" operator?
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 ...
.. 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 ...
Re: RegEx in Search and multi rename: where is the "NOT" operator?
"Find Files" -> "Advanced" (tab) -> mark "Attributes" - > unmark "Directory"Unfortunately I don't know any other solution to find only files in a search with TC,
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: RegEx in Search and multi rename: where is the "NOT" operator?
I bet @tuska is intelligent enough to have understood that the first time ..
(still no sign of @Christo ...)
(still no sign of @Christo ...)
Re: RegEx in Search and multi rename: where is the "NOT" operator?
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".