This is an old revision of the document!

Masks

To use the following features of WinSCP you need to specify a mask (wildcard) to select files (or other things):

Advertisement

Basic Syntax

When specifying the mask you can use following patterns:

Pattern Meaning Example
* Matches any number (including zero) of arbitrary characters. *.doc; about*.html
? Matches exactly one arbitrary character. photo????.jpg
[abc] Matches one character from the set. index_[abc].html
[a-z] Matches one character from the range. index_[a-z].html

Advertisement

All other characters are treated literally (except for special characters used in contructs decribed below).

To escape character with special meaning in patterns (*?[) enclose it into set pattern, e.g. filewithstar[*].

Size and Time Constraints

File mask can be followed by these size and time constraints:

Pattern Meaning Example
>size[KMG] Matches files larger than size. Following units can be used: K (Kibibyte), M (Mebibyte) or G (Gibibyte). *.bin>1M
<size[KMG] Matches files smaller than size. <1G
This feature is available only in the latest beta release.:
>yyyy-mm-dd[ hh:mm[:ss]] Matches files modified the last time after the date or time. >2012-01-01, >2012-02-29 08:47
>time[YDHNS] Matches files modified the last time within specified interval. One of the following units must be used: Y (years), D (days), H (hours), N (minutes’) or S (seconds). *.doc>1Y
<yyyy-mm-dd[ hh:mm[:ss]] Matches files modified the last time before the date or time. *.doc<2012-02-29 08:54:21
<time[YDHNS] Matches files modified the last time before specified interval. <60D

It is also possible to use operators >= and <=.

To escape operator character (<>) double it, e.g. filewith<<lessthan.

Combining Masks

In most contexts (basically everywhere except for script commands), you can combine several masks using semicolon (;) or comma (,).

For example following mask includes all JPG and GIF images: *.jpg; *.gif.

To escape separator character double it, e.g. filewith,,comma.

Include and Exclude Masks

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 2010: *.jpg; *.gif | 2010*.

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.

In releases prior to the next release, in transfer settings, it was possible to explicitly select whether the file mask is include or exclude mask. When exclude file mask was selected, the order of exclude and include mask was reverted. Mask was starting with exclude mask, optionally followed by pipe and include mask.

Advertisement

To escape pipe character double it, e.g. filewith||pipe.

Directory Mask

In the Next Release

To use the mask for directories, append a slash to the end, e.g. images/. The mask */ matches any directory.

To make operation non-recursive use exclude mask */.

Directory masks are recursive. E.g. mask images/ matches directories /home/martin/images/ as well as /home/martin/images/avatars/.

In Previous Releases

Particularly when specifying an include mask for transfers, bear in mind that it is applied to directories as well, so that *.bak will only match backup files located in the current directory (unless you happen to have a subdirectory whose own name ends in “.bak”, in which case it will be applied to all backup files in there too).

A mask ending with slash matches only directories. The mask */ matches any directory.

For example to transfer only HTML files located in any directory, use the include mask */; *.html (see below for combining masks).

To make operation non-recursive use exclude mask */.

Path Mask

When the 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 and its subdirectories (in the next release only).

In releases prior to the next release the previous mask does not match files in subdirectories. To match all text files within subtree, use mask /home/martinp/*.txt; /home/martinp/*/*.txt1.

For a relative 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, the mask */public_html/*.bak will match backup files both in D:\Documents\public_html\ and /home/martinp/public_html/.

You can also specify full path to specific file or directory, both local and remote. For example if you want to match only specific .csv directory, not all, use /home/martinp/data/.csv/ instead of .csv/.

Exceptions

For convenience, a masks *.* and *. are exceptions matching any file and any file without an extension, respectively, even if its name does not include any dot.

  1. Simpler, but less precise, form would be /home/martinp*/*.txtBack

Advertisement

Last modified: by martin