/
UDM - forfiles Statement - Generic Character Substitution into Variables
UDM - forfiles Statement - Generic Character Substitution into Variables
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
- A generic file pattern of A?C.txt applied to ABC.txt will return B as the value of $(_file.wildcard0) variable.
- 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).
- 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:
, multiple selections available,
Related content
UDM - forfiles Statement - Generic Character Substitution into Variables
UDM - forfiles Statement - Generic Character Substitution into Variables
More like this
UDM - forfiles Statement - Generic Character Substitution into Variables
UDM - forfiles Statement - Generic Character Substitution into Variables
More like this
UDM - forfiles Statement - Generic Character Substitution into Variables
UDM - forfiles Statement - Generic Character Substitution into Variables
More like this
UDM - forfiles Statement - Generic Character Substitution into Variables
UDM - forfiles Statement - Generic Character Substitution into Variables
More like this
UDM - forfiles Statement - Generic Character Substitution into Variables
UDM - forfiles Statement - Generic Character Substitution into Variables
More like this
UDM - forfiles Statement - File Specification
UDM - forfiles Statement - File Specification
More like this