name (if it exists). This last rule can make interpretation of the results very tricky, because it is
not always obvious when the mask is matching via the short name.
It is possible to use RegEdit to disable the generation of short 8.3 names on NTFS volumes, at
which point interpretation of file mask results is much more straight forward. Any
short names
that were generated before disabling short names will remain.
TargetMask
The
TargetMask
specifies the new name. It is always applied to the full long name;
The
TargetMask
is never applied to the short 8.3 name, even if the
SourceMask
matched the
short 8.3 name.
The presence or absence of wildcards in the
SourceMask
has no impact on how wildcards are
processed in the
TargetMask
.
In the following discussion
c
represents any character that is not
*
,
?
, or
.
The
TargetMask
is processed against the source name strictly from left to right with no back-
tracking.
c
Advances the position within the source name as long as the next character is not . and
appends c to the target name. (Replaces the character that was in source with c, but never
replaces .)
?
Matches the next character from the source long name and appends it to the target name as
long as the next character is not . If the next character is
.
or if at the end of the source name
then no character is added to the result and the current position within the source name is
unchanged.
*
At end of sourceMask - Appends all remaining characters from source to the target. If already
at the end of source, then does nothing.
*c
Matches all source characters from current position through the last occurance of c (case
sensitive greedy match) and appends the matched set of characters to the target name. If c is
not found, then all remaining characters
from source are appended, followed by c This is the
only situation I am aware of where Windows file pattern matching is case sensitive.
*.
Matches all source characters from current position through the last occurance of . (greedy
match) and appends the matched set of characters to the target name. If . is not found, then all
remaining characters from source are appended, followed by .
*?
Appends all remaining characters from source to the target. Any
additional characters after
the *? in sourceMask will be appended to target. If already at end of source then does nothing.
.
without
*
in front - Advances the position in source through the first occurance of
.
without
copying any characters, and appends
.
to the target name. If
.
is
not found in the source, then
advances to the end of source and appends
.
to the target name.
After the
TargetMask
has been exhausted, any trailing . and {space} are trimmed off the end of
the resulting target name because Windows file names cannot end with . or {space}
It appears these same rules also work for the target name of the COPY commmand.
Chia sẻ với bạn bè của bạn: