Detect String In Files

Searches for the input string in all files under the given path, or in files matching the given filename

patterns.

Arguments Description

st (str): the string to search for (a regex pattern in case regex=True).

path (str): the path to the files’ folder.

files_name_pattern (str, optional): Filenames or patterns separated by “,”. The default value is None.

regex (bool, optional): Whether to match against regular expressions or to look for substring

Returns

bool: True if the string has been detected, otherwise False.

Examples

# To search for the string in all files under the given path :
${res}= Detect String In Files Dtc ${dtc_report_path}
# To search for the string in files whose name begins with “dtc” :
${res}= Detect String In Files Dtc ${dtc_report_path} dtc*
# To search for the string in the “dtc_report.txt” file :
${res}= Detect String In Files Dtc ${dtc_report_path} dtc_report.txt
# To search for the string in “svk_report.txt” file and files whose name begins with “dtc”:
${res}= Detect String In Files Dtc ${dtc_report_path} dtc*,svk_report.txt
${res}= Detect String In Files Dtc ${dtc_report_path} dtc_report.txt,svk*

Note

Specifying the file name or its name pattern will optimize the search.