FILEFIND.GREP_RECURSE Function
Syntax
Arguments
- file_patternCharacter
A pattern to select file names using wildcard characters like '*' and '? '.
- regular_expressionCharacter
A regular expression used to search the directory.
- file_attribute
Default = 0 (normal files). The File_Attribute parameter is a numeric value specifying the type of file to find. You can find files that have one or more of the following attributes:
- File Attribute
- Description
- FILE_FIND_NORMAL
Normal
- FILE_FIND_READONLY
Read-only
- FILE_FIND_HIDDEN
Hidden
- FILE_FIND_SYSTEM
System
- FILE_FIND_LABEL
Label
- FILE_FIND_DIRECTORY
Directory
- FILE_FIND_ARCHIVE
Archive
- FILE_FIND_AND_FLAGS
Specifies that multiple flags should be ANDed together rather than ORed. By default flags are ORed.
- FILE_FIND_NOT_READONLY
Files that are NOT readonly
- FILE_FIND_NOT_DIRECTORY
Files that are NOT directory files
- FILE_FIND_NOT_ARCHIVE
Files that do not have their archive bit turned on.
- FILE_FIND_AND_NOT_FLAGS
Specifies that when multiple "NOT" flags are used that the flags should be ANDed together.
- grep_formatCharacter
Character
- \0
All text.
- \N
Tagged text expression.
- N
No copy of unmatched text.
- F
Only process first match.
- $(OFFSET)
Return the offset of the match.
- $(LENGTH)
Return the length of the match.
- $(END)
Return the ending offset of the match.
- $(LINE)
Return the line the match started on.
- $(ENDLINE)
Return the line the match ended on.
- $(LINES)
Return the number of lines the match crosses.
- $(LINETEXT)
Return the complete line(s) of text the match(es) occurred on.
- $(LINEOFFSET)
Return the offset of the beggining of the match line.
- $(ENDLINEOFFSET)
Return the offset of the end of the line the match ended on.
- $(COUNT)
Return the number of matches encountered so far.
- $(NEXTLINE)
Advance the search pointer to the next line.
- $(FILENAME)
The name of file we are currently grepping
- $(FULLFILENAME)
The fully qualified name of file we are currently grepping
- $(RELATIVEFILENAME)
A partially qualified name of file we are currently grepping (only different than FILENAME if we using recursive function)
- $(STOP)
Stops GREPing a file after one occurance is found. This lets you print a list of files that have a match instead of all the lines that in the file than matched.
- regex_optionsCharacter
Default = "S". Specify which compatibility with a common implementation. ThE flags for Emacs, Awk, Grep, Egrep and Sed conventions allow the pattern to follow the conventions of those utilities (which have slightly different variants regarding what is escaped and what is not escaped).
- Regex Option
- Description
- I
Ignore case
- E
Follow Emacs conventions
- A
Follow Awk conventions
- G
Follow Grep conventions
- EG
Follow Egrep conventions
- S
Follow Sed conventions
- X
Extended (similar to Awk but no need to escape '' inside of [])
Returns
- Line_ListCharacter
A list containing of one line per file that contains text that matches the Regular_Expression. Each line contains the filename, line number, and the line containing the matching text.
Description
Same as grep() but recurses subdirectories.
Discussion
The FILEFIND.GREP_RECURSE() method executes a regular expression against the contents of the files in the current directory and its sub-directories that match a specified file pattern and returns a list of filenames and text.
Example
file.dir_put("c:\\") ? FILEFIND.grep_recurse("*.txt", "(W|w)indows") = ALPHA4V8\README.TXT 26:Running With Windows 95 ALPHA4V8\README.TXT 33: Using Alpha Four with Microsoft Windows for Workgroups ALPHA4V8\README.TXT 136:To configure Windows for Workgroups to work properly with Alpha Four, ALPHA4V8\README.TXT 429:Field Rules: Lookup Windows can Now Use Custom Column Headings and Custom Textpad\README.TXT 15: o MS Windows 95, NT 3.51, or later versions of Windows. Textpad\README.TXT 15: o MS Windows 95, NT 3.51, or later versions of Windows. Textpad\README.TXT 20: Please note that Windows 3.1 with Win32s is not supported. frame55\fmreg.txt 25:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\FRAMEMAKER.EXE frame55\Readme.txt 31:file named README (Readme.txt, in Windows). This file is in the frame55\FrameLog_00.01.28_16.12.44.txt 6:Window System: MSWindows
See Also