Wildcard Matching

You can quickly send or get multiple files at once using local or remote pattern matching.  You can also delete multiple remote files with pattern matching.  The patterns are formed by including wildcard characters in the source pathnames.  The exact syntax of the patterns depends on whether they are local or remote, and what operating systems are being used.

The local command shell parses wildcard characters before movedat sees them.  Wildcards in the local path will be interpreted by the local shell.  Wildcards in the remote path must be properly quoted or escaped so that they can be passed to the server.

The behavior of wildcards will vary depending on the local and remote systems.  For example, Windows only supports wildcards in the base name of the file, not in the path name.  You can test which files will match a remote pattern by using the -F option.  You can disable remote wildcards by using the -g or NoGlob option.

* Star, Asterisk, Splat

This matches zero or more characters in a pathname component.  For example, applying the pattern t*.txt to the following file list:

test1.txt t.txt myfile.txt twenty.dat tuesday.dat

would match test1.txt and t.txt, but not myfile.txt, not twenty.dat, and not tuesday.dat.  The star wildcard is supported in both Windows and Unix.

? Question Mark

This matches exactly one character in a pathname component.  For example, applying the pattern test?.txt the following file list:

test1.txt test17.txt test2.txt test3.dat

would match test1.txt and test2.txt, but not test17.txt and not test3.dat.  The question mark wildcard is supported in both Windows and Unix.

[ Bracket

This construct matches a range of single characters in a pathname component.  For example, applying the pattern test[1-3].txt the following file list:

test1.txt test17.txt test2.txt test3.dat test4.txt

would match test1.txt and test2.txt, but not test17.txt, test3.dat, nor test4.txt.  The bracket wildcard is not supported by Windows.

Size Limit

The server currently limits the results of remote wildcard matching to 8 megabytes.  This may truncate your results if a pattern matches millions of files.

Upper vs. Lower Case

Windows and macOS allow file names to match if they differ only by the case of some letters.  Most other unix filesystems require an exact case match.  It is best to avoid using filenames that differ only by the case of some letters, and try to match case exactly.

Character Escaping

When you are using wildcards to match local files for sending, the pattern must be parsed by your local command shell.  But when you want to use wildcards to download or delete remote files, the local shell must pass the characters through unchanged so that the server can see them.

In unix, you can tell the shell to ignore wildcards either by enclosing the entire argument in quotes, or by preceding each wildcard with a backslash.  For example:

movedat me@example.com:subdir/files\*.txt mydir
movedat "me@example.com:subdir/files*.txt" mydir

In Windows, you can escape wildcards by using quotes:

movedat "me@example.com:subdir/files*.txt" C:\mydir

If you are having trouble getting wildcard patterns to work ("no match" errors), make sure that your remote patterns are escaped according to the rules of your local shell.

If you need to send the wildcard characters *, ?, or [ as part of the literal remote path, use the -g or NoGlob option to disable remote path globbing.

Server Directory Traversal (Dot Dot)

The pseudo-files "." and ".." are not included in servedat's wildcard output.

If the user is subject to RestrictHome, then results which include ".." in the path will be suppressed and a warning logged.

Explicit use of ".." in the original pattern may cause unexpected results as servedat attempts to resolve those before wildcard processing and without regard to wildcard syntax.

On unix systems, wildcards and ".." can interact with symbolic links in unexpected ways.  See the Known Issues chapter for an example.

Example

The following Windows batch script uses the "-F" option to retrieve a list of remote files, then downloads each one and deletes the source only when the download succeeds.

FOR /F "delims=" %%A IN ('movedat.exe -F user@example.com:*') DO ( movedat.exe -y "user@example.com:%%A" . IF ERRORLEVEL 1 ( ECHO Skipping "%%A" due to errors. ) ELSE ( movedat.exe -x "user@example.com:%%A" ) )

Prior to running this script, it would be necessary to store the password in the encrypted password cache.

movedat.exe -A user@example.com:

See Also

Wildcards are used to match top-level names on the command line, while PatternMatch filters apply to file names inside listings and folder transfers.