Regex in search list file

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
ivasht2
Junior Member
Junior Member
Posts: 3
Joined: 2022-03-25, 17:18 UTC

Regex in search list file

Post by *ivasht2 »

Hello,
sorry for question. More likely someone has asked it before, but I couldn't find the answer.
I read in help (F1) that for searching files one may use the text file with a list of files (dirs) to search for.
In the "Search in " field you should input something like in the form @c:\path\filelist.txt.
Also it is said that text file also supports wildcards and regular expressions.
With a list of files in that text file TC perform search well .However if I write Regex in that text file TC stopps searching.
Am I do something incorrect?
User avatar
white
Power Member
Power Member
Posts: 5986
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Regex in search list file

Post by *white »

Total Commander's Help wrote:
Sample list: Description
c:\testdir\ Searches "c:\testdir" for files defined in "search for"
c:\testdir\*.txt *.doc Searches "c:\testdir" for txt and doc files
c:\testdir\<regular expression Searches "c:\testdir" using regular expression
c:\testdir\filename.txt Searches just for "filename.txt" in "c:\testdir"
In the sample list you see that you have to start the regular expression with a less than sign "<", followed by a regular expression.
So a line in the list file could look like this:

Code: Select all

c:\testdir\<\.pdf$
Which means search in c:\testdir and sub folders for files with filename extension .pdf

For lines in the list file containing a folder name only the Search for field is used.
So if you put "\.txt$" (without quotes) in the Search for field and enable RegEx, this regex search will be done for these lines.
For example:

Code: Select all

Search for:	\.txt$
Search in:	@mylistfile
RegEx:		Enabled

Contents of mylistfile:
c:\testdir1\
c:\testdir2\
c:\testdir3\<\.pdf$
c:\testdir4\*.doc
Searches for .txt files in testdir1 and testdir2, searches for .pdf files in testdir3 and searches for .doc files in testdir4.
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Regex in search list file

Post by *Stefan2 »

Hi and welcome.


- open the search
- click at [Help]
- read:

Search in: You can enter the name of a text file containing a list of files and directories to be searched, in the form @c:\path\filelist.txt.
The file must contain one file/directory name per line, either an absolute path, or relative to the location of the list file.
The text file now also supports wildcards ( * and ? ) and regular expressions.
c:\testdir\*.txt *.doc --- Searches "c:\testdir" for txt and doc files
c:\testdir\<regular expression --- Searches "c:\testdir" using regular expression

Note the enabler sign < to treat the following as RegEx



- - -


BTW: the German help only talks about Platzhalter * und ?
Suchen in: Sie können auch eine Textdatei mit einer Liste der zu durchsuchenden Dateien und Verzeichnisse angeben, in der Form @c:\Pfad\Dateiname.txt.
Die Textdatei muss einen Datei-/Verzeichnisnamen pro Zeile enthalten, entweder als absoluten Pfad, oder relativ zum Verzeichnis der Listendatei.
In der Listendatei dürfen nun auch die Platzhalter * und ? (sowie Reguläre Ausdrücke) verwendet werden.
c:\testdir\*.txt *.doc --- Sucht in "c:\testdir" nach txt- und doc-Dateien
c:\testdir\<RegEx --- Sucht in "c:\testdir" mit dem regulären Ausdruck





 
ivasht2
Junior Member
Junior Member
Posts: 3
Joined: 2022-03-25, 17:18 UTC

Re: Regex in search list file

Post by *ivasht2 »

Interesting, using @myfile with regex lines like c:\testdir3\<\.pdf$ works fine ( I left "Search for" field blank). However, when I paste c:\testdir3\<\.pdf$ directly in "Search in" field I got the message "Search path not found!". The same message displayed if I input directly in the "Search field" the c:\testdir3\*.pdf.
User avatar
nsp
Power Member
Power Member
Posts: 1948
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Regex in search list file

Post by *nsp »

ivasht2 wrote: 2022-03-25, 20:11 UTC Interesting, using @myfile with regex lines like c:\testdir3\<\.pdf$ works fine ( I left "Search for" field blank). However, when I paste c:\testdir3\<\.pdf$ directly in "Search in" field I got the message "Search path not found!". The same message displayed if I input directly in the "Search field" the c:\testdir3\*.pdf.
The line inside search file c:\testdir3\<\.pdf$ with regex is equivalent to :
Shearch for: <\.pdf$
Search in:c:\testdir3\
You cannot enter a path in search for field !
ivasht2
Junior Member
Junior Member
Posts: 3
Joined: 2022-03-25, 17:18 UTC

Re: Regex in search list file

Post by *ivasht2 »

thanks, I noticed entering the symbol '<' before regex in the "Search for" does turning on the switch in the "RegEx" field.
Post Reply