HFS: File masks: Difference between revisions

From rejetto wiki
Jump to navigation Jump to search
m (File masks moved to HFS:filemasks)
m (Reverted edits by 217.116.232.113 (Talk); changed back to last version by Rejetto)
 
(36 intermediate revisions by 13 users not shown)
Line 1: Line 1:
== What is it? ==
== What is it? ==


A file mask denotes a set of files. It is something like this: <tt>*.jpg;*.gif</tt>. This example denotes any jpeg and gif files.
A file mask denotes a set of files. It is usually something like this: <tt>*.jpg;*.gif</tt>. This example denotes any jpeg and gif files.
Remember that the characters used in filenames are not case sensitive: so  <tt>*.jpg</tt> and <tt>*.JPG</tt> refer to exactly the same set of files.


== How does it work? ==
== How does it work? ==


The example above shows a <i>double</i> file mask. It has two atoms separated by the semicolon: <i>*.jpg</i>
The example above shows a ''double'' file mask. It has two atoms separated by the semicolon: ''*.jpg''
and <i>*.gif</i>. Then semicolon is used to merge multiple masks: it is a <i>special</i> character.
and ''*.gif''. The semicolon is used to merge multiple masks: it is a ''special'' character.
There are only 3 special characters in file masks: <b>;</b> <b>*</b> and <b>?</b>.
There are only three special characters in file masks: ''';''' '''*''' and '''?'''.


== The star (*) ==
== The star (*) ==


stands for <i>any string</i> of characters. If the mask contains only the star, it would match ANY file.
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 <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 18:
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.


Moreover <tt>A*B</tt> matches any file starting with an A and ending with a B.
<tt>A*B</tt> matches any file starting with an A and ending with a B.
In the example above, you find <i>*.jpg</i> : it matches any file ending with .jpg that is jpeg images.
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.
Well, know that jpeg files sometimes ends with <i>.jpeg</i> and rarely with <i>.jpe</i> .


The star matches also the <i>null string</i>: <tt>a*.jpg</tt> matches files like <i>a1.jpg</i> , <i>adfgg.jpg</i>
The star also matches the ''null string'': <tt>A*.jpg</tt> matches files like ''A1.jpg'' , ''Adfgg.jpg''
but also <i>a.jpg</i> , where the star has been replaced with nothing.
but also ''A.jpg''.


== The question point (?) ==
== The question mark (?) ==


stands for a <i>single character</i>. Something like <tt>A?B</tt> matches any 3 chars long filename,
This stands for a ''single character''. Something like <tt>A?B</tt> matches any filename that is three characters long and starts with an A and ends with a B. The length is fixed to three characters because ? can be replaced by
starting with an A and ending with a B. The length is fixed to 3 characters because ? can be replaced by
only one character. Thus the ? does not match the null string as the * does.
only one single character. Thus the ? does not match the null string as the * does.
 
 
==Inverting the logic (\) ==
 
So you want to hide filetypes, instead of showing specific filetypes?
 
Insert a backslash <tt>\</tt> before <tt>*.ext</tt> to achieve opposite logic with the filter, and hide the filetypes you do not want visible to users. E.g <tt>\*.db;*.ini</tt>

Latest revision as of 10:48, 8 February 2008

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. Remember that the characters used in filenames are not case sensitive: so *.jpg and *.JPG refer to exactly the same set of 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 (?)

This stands for a single character. Something like A?B matches any filename that is three characters long and starts with an A and ends with a B. The length is fixed to three characters because ? can be replaced by only one character. Thus the ? does not match the null string as the * does.


Inverting the logic (\)

So you want to hide filetypes, instead of showing specific filetypes?

Insert a backslash \ before *.ext to achieve opposite logic with the filter, and hide the filetypes you do not want visible to users. E.g \*.db;*.ini