Directory Listener: Exact Match File Restriction
The Directory Listener has an option called “File/folder name restriction”. If set, only files matching that restriction will be retrieved by the directory listener. If the value of this setting is found anywhere in the filename, then the file is retrieved. So for example, the following settings will retrieve any files that contain “report” in the filename including “report.txt” and “test_report.txt”:
If you want to restrict to filenames that exactly match a given filename, you will need to use the regular expression (RegEx) syntax. This is done by prepending the “^” character (which matches the beginning of the name) and appending the “$” character (which matches the end of the name). So setting the “File/folder name restriction” to “^report$” will cause the directory listener to retrieve “report.txt”, but not “test_report.txt” or “report_test.txt”.
Also worth noting is that the filename restriction is case-sensitive by default. So a restriction of “report” will not match a file named “REPORT.txt”. Again we can use the regular expression syntax to ignore the case by including “(?i)” at the beginning. So for example, “(?i)^report$” would match “report.txt”, “Report.txt” and “REPORT.txt”.
The above are just a couple of examples of regular expressions. To learn more about regular expressions, do an internet search for “java regular expression tutorial”.