HFS: File masks: Difference between revisions
m (→What is it?) |
|||
Line 11: | Line 11: | ||
== The star (*) == | == The star (*) == | ||
stands for <i>any string</i> of characters. If the mask contains only the star, it | The star (also called "asterisk") stands for <i>any string</i> of characters. If the mask contains only the star, it matches ANY file. | ||
If you put an A before the star <tt>A*</tt>, it matches any file starting with an A. | If you put an A before the star <tt>A*</tt>, it matches any file starting with an A. | ||
Line 17: | Line 17: | ||
If you put an A after the star <tt>*A</tt>, it matches any file ending with an A. | If you put an A after the star <tt>*A</tt>, it matches any file ending with an A. | ||
<tt>A*B</tt> matches any file starting with an A and ending with a B. | |||
The example above shows <i>*.jpg</i> : it matches any file ending with .jpg (that is, jpeg images). jpeg files are relatively unusual because they sometimes end with <i>.jpeg</i> and more rarely with <i>.jpe</i> . (The part of a filename that comes after the period is called the file "extension", and is normally limited to three characters.) You could use the mask .jp* to match all types of jpeg files. | |||
The star matches | The star also matches the <i>null string</i>: <tt>a*.jpg</tt> matches files like <i>a1.jpg</i> , <i>adfgg.jpg</i> | ||
but also <i>a.jpg</i> | but also <i>a.jpg</i>. | ||
== The question mark (?) == | == The question mark (?) == |
Revision as of 21:45, 9 October 2006
What is it?
A file mask denotes a set of files. It is usually something like this: *.jpg;*.gif. This example denotes any jpeg and gif files.
How does it work?
The example above shows a double file mask. It has two atoms separated by the semicolon: *.jpg and *.gif. The semicolon is used to merge multiple masks: it is a special character. There are only three special characters in file masks: ; * and ?.
The star (*)
The star (also called "asterisk") stands for any string of characters. If the mask contains only the star, it matches ANY file.
If you put an A before the star A*, it matches any file starting with an A.
If you put an A after the star *A, it matches any file ending with an A.
A*B matches any file starting with an A and ending with a B. The example above shows *.jpg : it matches any file ending with .jpg (that is, jpeg images). jpeg files are relatively unusual because they sometimes end with .jpeg and more rarely with .jpe . (The part of a filename that comes after the period is called the file "extension", and is normally limited to three characters.) You could use the mask .jp* to match all types of jpeg files.
The star also matches the null string: a*.jpg matches files like a1.jpg , adfgg.jpg but also a.jpg.
The question mark (?)
stands for a single character. Something like A?B matches any 3 chars long filename, starting with an A and ending with a B. The length is fixed to 3 characters because ? can be replaced by only one single character. Thus the ? does not match the null string as the * does.