File name filtering
This can be useful in this situation:
You want to download data files with a .dat file name extension, but the process that writes those files takes a long time. To prevent that partially written files are downloaded, the process that writes the files should write them with a .tmp extension. After a file has been completely written, it should be renamed to .dat. To ensure that only the completed .dat files are downloaded, you must use a file name filter that matches .dat but not .tmp .
The filter is applied to the name of the file, not to any folders in the file path. For example, if the source folder contains a subfolder abc with a file called 123.dat, the filter is applied to 123.dat, not to abc/123.dat.
You can specify the filter as a wildcard expression or as a regular expression. The filter can be case-sensitive or case-insensitive.
In a wildcard expression, two characters have a special meaning:
- A question mark (?) matches any character.
- An asterisk (*) matches zero or more characters.
A regular expression has more characters with a special meaning. It can be used for more complicated filters where a wildcard does not suffice. For more information on regular expressions, see https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference.
Examples
This table shows some examples of wildcard expressions:
Wildcard expression | Description |
---|---|
*.dat | Matches all files with a .dat extension. abc.dat and ABC.dat match. abc.DaT does not match if the expression is case-sensitive, but matches if the expression is case-insensitive. abc.tmp and abc.dat2 do not match. |
a*.txt | Matches all files that start with "a" and
end in a .txt extension. a.txt, a1.txt, and abc.txt match. Abc.txt and abc.TXT only match if the expression is case-insensitive. 0a.txt and a.txt.tmp do not match. |
a??.txt | Matches all files that start with "a" followed by two characters, and end in a .txt extension. abc.txt and a12.txt match. ABC.txt and a12.txT only match if the expression is case-insensitive. a1.txt and a123.txt do not match. |
This table shows some examples of regular expressions:
Regular expression | Description |
---|---|
\.(txt|dat)$ | Matches all files with a .txt or .dat extension. |
\.(?!tmp$)[^.]+$ | Matches all files with an extension other than .tmp. |
^a\d{2}\.txt$ | Matches all files that start with "a" followed by two digits, and end in a .txt extension. |