UDM - Copying Multiple Files Using Wildcards or Regular Expressions


Introduction

In addition to copying single files, the copy command can be used to copy multiple files by using wildcards or regular expressions in the source file specification. If they are used, any file matching the source file specification will be copied.

Wildcards

Types of Wildcards

There are two types of wildcards:

  1. Asterisk (*) wildcard matches zero or more characters.
  2. Question mark (?) wildcard matches a single character.

Examples

Here are some examples of wildcard matching given the following file names in the source directory:

  • test.txt
  • test1.txt
  • test2.txt
  • test3.txt
  • test.bin
  • test1.bin
  • test2.bin
  • test3.bin

Source File Specification

Files Copied

*, *.*, test*.*, tes?*.*

Matches and copies all of the files in the directory.

*.txt

Matches and copies the first four files.

*.bin

Matches and copies the last four files.

test?.txt

Matches and copies files test1.txt, test2.txt, and test3.txt.

Regular Expressions

Types of Regular Expressions

POSIX Extended Regular Expression syntax is used for file name matching.

Examples

Here are some examples of regular expression matching given the following file names in the source directory:

  • test.txt
  • test1.txt
  • test2.txt
  • test3.txt
  • test.bin
  • test1.bin
  • test2.bin
  • test3.bin

Source File Specification

Files Copied

.+, tes.+, te.+[tn]$

Matches and copies all of the files in the directory.

.+txt$

Matches and copies first four files.

.+bin$

Matches and copes the last four files.

te..[123].+bin$

Matches and copies the last three files.

Usage

Wildcards and regular expressions can be used only in the source file specification, not the destination file specification.

Under some operating systems, it is possible for * and ? to be valid characters in a file name. When they appear in the destination portion of a UDM copy operation, they are treated as file characters and not as wild cards.

Also, keep in mind that while UDM can copy all of the files at a single directory level in a hierarchical file system, it will not traverse the directory tree and copy files from directories at a lower level than the current directory or the directory explicitly specified in the source file specification.

Wildcards and regular expressions should appear only in the file name portion of the file specification and not as part of the directory itself.