To use the following features of WinSCP you need to specify a mask (wildcard) to select files (or other things):
TransferOptions.FileMaskin .NET assembly.
You can use File Mask dialog to help you with assembling the mask.
When specifying the mask you can use following patterns:
||Matches any number (including zero) of arbitrary characters.||
||Matches exactly one arbitrary character.||
||Matches one character from the set.||
||Matches one character from the range.||
All other characters are treated literally (except for special characters used in the constructs described below).
To escape character with special meaning in patterns (
*?[) surround it by set pattern, e.g.
File mask can be followed by these size and time constraints:
||Matches files larger than
Note that directories are considered to have a zero size.
Following units can be used:
||Matches files smaller than
||Matches files modified the last time after the date or time (i.e. “newer than”).||
||Matches files modified the last time within specified interval (i.e. “newer than”).
One of the following units must be used:
||Matches files modified the last time before the date or time (i.e. “older than”).||
||Matches files modified the last time before specified interval (i.e. “older than”).||
It is also possible to use operators
To escape an operator character (
<>), double it, e.g.
To combine constraints, append one after another, without any separators (or use spaces). E.g. to select all
.doc files created in 2013:
Note that if your constraint contains spaces (particularly constraint with date and time), to use it in scripting, you need to enclose whole mask to double-quotes.
For example following mask includes all JPG and GIF images:
To escape separator character double it, e.g.
Mask can combine include and exclude mask separated by pipe (
For example following mask includes all JPG and GIF images, but excludes those starting with
*.jpg; *.gif | 2010*; 2011*.
Both include and exclude part can be empty, denoting that everything is included or nothing is excluded, respectively. When include part is empty, masks starts with pipe straight away. When exclude part is empty, you can omit the trailing pipe.
Exclude mask takes precedence over include mask. I.e. when the same file is matched by both the exclude and include mask, it is excluded.
To escape pipe character double it, e.g.
To use the mask for directories, append a slash to the end, e.g.
images/. The mask
*/ matches any directory.
Note that when using File Mask dialog, the trailing slash for directory masks is appended automatically.
To make operation non-recursive use exclude mask
Directory masks are recursive. E.g. mask
images/ matches directories
/home/martin/images/ as well as
When a mask selects files and it makes sense to select them based on directory, you can extend the mask with a path mask. You should separate the path mask from the filename mask by a slash. For example mask
/home/martinp/*.txt matches all text files within the directory. To match all text files within subtree, use mask
The path mask is matched against full path, i.e. not against path relative path to a root of file transfer or synchronization. E.g. mask
public_html/wiki/ does not match
/home/martinp/public_html/wiki directory, even if the root of file transfer or synchronization is
/home/martinp. Partial path mask that matches an absolute path may look like
For a partial path mask it makes no difference whether you use back (
\) or forward slashes (
/); the mask will always work for both local and remote paths. For example, a mask
*/public_html/*.bak will match backup files both in
You can also specify full path to a specific file or directory, both local and remote. For example if you want to match only a specific
.csv directory, not all, use
/home/martinp/data/.csv/ instead of
For convenience, mask
*.* is an exception matching any file or directory, even if its name does not include any dot. On the contrary, mask
*. matches any file or directory without an extension.
-filemaskswitch in scripting and
TransferOptions.FileMaskin .NET assembly.
|*/, where the
|denotes a start of an exclude mask.
Site design by Black Gate