Karen's Patterns Tip Sheet
(Revised September 7, 2003)

What is a "Pattern"?
A Pattern allows you to specify a group of folders or files with a single string of text. To determine if a particular folder or file matches the pattern, the Replicator compares each character of the folder or file's name to the characters in the pattern. If all characters match exactly (ignoring the difference between upper- and lower-case letters), the folder or file matches the pattern.

But there's more... A pattern can contain special characters. These match one or more of the characters in a folder or file's name. 

What are these Special Characters?
There are three commonly used pattern characters. They are:

? - Matches Any Single Character in the folder or file's name:

This Pattern	Matches 	Doesn't Match	
Week?.xls	Week1.xls	Week23.xls	
	week2.xls	Weekly.xls	
	WeekX.xls	Week1.doc	
Document.do?	Document.doc	Document.xls	
	document.dot		
Week??.xls	Week23.xls	Week1.xls	
	WEEKLY.xls	Week23.doc	
Folder?\Folder2\	Folder1\Folder2\	Folder\Folder2\	
	Folders\Folder2\	Folder1	

* - Matches Any Consecutive Series of Characters:

This Pattern	Matches	Doesn't Match	
Week*.xls	Week1.xls	Week1.doc	
	week2.xls	Sales Week1.xls	
	WeekX.xls		
	WEEK23.xls		
	Weekly Report.xls		
Document*	Document.doc	My Document.doc	
	document.dot	My Documents	
	DOCument1.doc	Docs	
	Document Folder		
	Document		
	Documentaries		
*Document*	My Document.doc	My Document.xls	
	All Documents.doc	Docs.doc	
	Document Folder		
	\My Documents\Music\		
Sales*Report	Sales Weekly Report	Weekly Sales Report	
	Sales (by District) Report	Sales Report (Weekly)	
	\Folder\Sales Report\	Sales Report.doc	
\*\Data\	\Folder\Data\	\Data\	
	\Temp\Data\	\Folder\Data1\	
	\Top\Middle\Data\		

# - Matches Any Single Numeric Digit (0 through 9):

This Pattern	Matches	Doesn't Match	
Week#.xls	Week1.xls	WeekX.xls	
Month##.xls	Month12.xls	Month1.xls	
	Month01.xls		
Year 200#	Year 2000	Year 2010	
	\Folder\Year 2004\	Year End	
	Year 2009	Year 200X	
		Year 2000.doc	
\Folder #\Folder 2	\Folder 1\Folder 2\	\Folder 01\Folder 2\	
	\Folder 9\Folder 2\	\Folder 1\Folder\	
		\Temp\Folder 1\Folder 2\	

Show Me More Examples
Here are some examples that use combinations of the three most common pattern characters:

This Pattern	Matches	Doesn't Match	
Week*.do?	Week1.doc	Week1.xls	
	Week1.dot	First Week.doc	
	Weekly Report.doc		
	Week.dot		
Document#.???	Document1.doc	Document1.html	
	Document3.htm	Document	
	Document9.xls	Document1	
Year 200#*	Year 2000	Year End	
	Year 2003 Report	Year 200X Report	
	Year 2005.doc		
Month ## * *	Month 12 Sales Report	Month 12 Sales	
	month 03 district sales	Month 3 Sales Report	
	Month 06 District Sales.doc	Month 03 District-Sales	

Advanced Pattern Matching
A pattern can also match any of a selected group of characters. The characters that should match are placed inside square brackets ("[" and "]").  

Note: If the first character inside the brackets is an exclamation point ("!"), then a match occurs only if the character of the folder or file name don't match any of the selected characters.

Note: When placed inside square brackets, the pattern characters *, ? and # lose their special meaning. They become ordinary *, ? and # characters, only matching other *, ? or # characters.

This Pattern	Matches	Doesn't Match	
Week[12345].doc	Week1.doc	Week6.doc	
	Week2.doc	Week1.dot	
	Week5.doc	Week.doc	
Week[!12345].doc	Week6.doc	Week1.doc	
	Week1.dot	Week2.doc	
[abcdefg]*	Annual Report.doc	Yearly Report.doc	
	district sales	Sales By District	
	bate	late	
	date	Rate	
	Fate	mate	
	Gate		
	Final Notice		
[!abcdefg]*	Yearly Report.doc	Annual Report.doc	
	Sales By District	district sales	
	late	bate	
	Rate	date	
	mate	Fate	
		Gate	
		Final Notice	
District [ab234] Report	District 2 Report	District Report	
	District A Report	District 1 Report	
		District 2	
		District A Report.doc	
District [[]One] Report	District [One] Report	District One Report	
District [#]# Report	District #1 Report	District 1 Report	
	District #2 Report	District #1 Report.doc	

Folders
When specifying a patter to match a folder, you can include backslash ("\") characters to specify multiple folders. If the first character of a pattern is a backslash, the pattern must match the entire path name (all folders, from the root on down). 

But if the first character of a folder pattern is not a backslash, only the last folder in the path name must match the pattern.  

Here are some examples that show both types of folder patterns:

This Pattern	Matches	Doesn't Match	
\Temp*\	\Temp\	\Folder\Temp\	
	\Temporary\		
	\Temporary Internet Files\		
\Folder\Temp*\	\Folder\Temp\	\Temp\	
	\Folder\Temporary\	\Temporary\	
		\Temporary\Internet Files\	
Temp*Folder\	\Temp Folder\	\Temp Folder\Data\	
	\Temporary Folder\	\Temporary Folders\	
	\Misc\Temp Folder\		
Temp\*\Folder\	\Data\Temp\X\Folder\	\Temp\Folder\	
	\Music\Temp\Cool\Folder\	\Music\Temp\Folder\	
\Data\Year ####\	\Data\Year 2004\	\Data\Year 04\	
	\Data\Year 1993\	\Data\Year\	
	\Data\Year\2199\		

More Information
Karen's Replicator has been the subject of several issues of Karen's Power Tools Newsletter. You may find the answer to your question in one of those back issues, which can be found on the Internet at http://www.karenware.com/powertools/ptreplicator.asp.

Copyright © 2003 Karen Kenworthy
All Rights Reserved