

(Note - a valid Windows name cannot end with. Matches itself or it can match the end of name (nothing) if no more characters remain. It will match as little or as much as is needed to enable subsequent characters to match.Īll non-wildcard characters must match themselves, with a few special case exceptions. * - Matches any 0 or more characters including. However it will match nothing without failure if at name end or if the next character is a. This wildcard is greedy - it always consumes the next character if it is not a. The wildcards work here the same as with any other command that filters file names. The sourceMask works as a filter to determine which files are renamed. Wildcards are not allowed in the path leading up to the file name. If the sourceMask does not match anything, then a "file not found" error results.Īlso, when renaming files, wildcards are only allowed in the file name portion of the sourceMask. If the sourceMask matches only folders and not files, then a syntax error is generated if wildcards appear in source or target. If the sourceMask matches at least one file, then the file(s) will be renamed and folders will be ignored. Note - REN can be used to rename a folder, but wildcards are not allowed in either the sourceMask or targetMask when renaming a folder. The behavior of the wildcards changes slightly between source and target masks. Both the sourceMask and targetMask can contain * and/or ? wildcards. RENAME requires 2 parameters - a sourceMask, followed by a targetMask. No tests were done with unicode in file names.

These rules were discovered after extensive testing on a Vista machine. I figure many others may be interested in what I discovered)

I got tired of not knowing the rules and decided to experiment on my own. (Yes - this is a case where I am posting a paired question and answer. Of course knowing the rules would also benefit batch development. If I knew the rules for how wildcards are processed then I figure I could use the RENAME command more effectively without having to resort to batch as often. Frequently I've had to resort to writing a small batch script with a FOR loop that parses each name so that I can build each new name as needed. I haven't been able to anticipate what works and what doesn't.
Namechanger wildcard trial#
I've managed to successfully use wildcards in the filename2 parameter on some occasions, but it has always been trial and error. Not much help - there are many ways that statement can be interpretted. If you use wildcards in filename2, the characters represented by the wildcards will be identical to the corresponding characters in filename1." "You can use wildcards ( * and ?) in either file name parameter. Here is all it has to say regarding wildcards: The Microsoft technet XP online help isn't much better. The built in HELP facility is of no help - it doesn't address wildcards at all. How does the Windows RENAME (REN) command interpret wildcards?
