Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Overview

In order to capture the parts of a file name string specified to the forfiles statement, values represented by the * and ? generic characters can be stored in variables.

Up to 10 substitutions can be made (that is, 10 tokens stored into variables). Substitutions can be made to a variable for forfiles - $(_file.wildcardn) - where n is an integer between 0 and 9.

Wildcard Expansion Behavior

Wildcard expansion behavior is as follows:

  • All ? wildcards must be satisfied.
  • Expansion is performed left to right.
  • If a * wildcard is encountered, it will expand as far as it can without infringing on the guaranteed expansion of ? wildcards.
  • Secondary * wildcards in a wildcard string (for example, ***, *?*?*, and so on) will expand to zero length strings.

Example 1

  1. A generic file pattern of A?C.txt applied to ABC.txt will return B as the value of $(_file.wildcard0) variable.
  2. A generic file pattern of A?C*.txt applied to ABCDEF,txt will return B as the value of $(_file.wildcard0) and DEF as the value of $(_file.wildcard1).
  3. A generic file pattern of ??*.txt applied to ABCDEF,txt will return A as the value of $(_file.wildcard0), and B as the value of $(_file.wildcard1), and CDEF as the value of $(_file.wildcard1).
     

If c:\data contains the following files:

2015-CLIENTA-05DATA.xml
2015-CLIENTB-10WIDGETS.xml

The following code:

Will result in:

Example 2

Given a file name of 0123456789abc.xml:

A pattern of *???.xml would yield:

 

A pattern of ???*.xml would yield:

 

A pattern of ?*?.xml would yield:

 

A pattern of ?*?*?*?.xml would yield:

  • No labels