Using File/Directory Names Masks
Masks of file names are an easy and convenient tool for "sifting out" the data. By using masks, you can easily specify which files and directories should be processed and which should be ignored. There are five important points about masks that should be known:
First of all, let's understand what the point #1 means. There are several situations, where it may be very convenient to split the masks into file names masks and directory names masks. For example, we want to copy all the *.htm files from c:\data directory and all it's subdirectories. It is easy, we are using inclusive file name mask:
nnbackup.exe -i c:\data -o d:\backup -s -m *.htm
Explanation: Copy all htm-files from c:\data directory and all it's subdirectories into d:\backup.
Now, what if we want to exclude the c:\data\wrong_data subfolder from file processing? Exclusive directory name mask can help us:
nnbackup.exe -i c:\data -o d:\backup -s -m *.htm -dx "wrong_data"
Explanation: Copy all htm-files from c:\data directory and all it's subdirectories (except c:\data\wrong_data) into d:\backup.
The point #2. As you have already seen in the previous example there are inclusive and exclusive masks. Using an exclusive mask is very easy: all files will be processed except those that match the mask. For example:
nnbackup.exe -i c:\data -o d:\backup -x *.txt
Explanation: Copy all files except those with txt extension from c:\data to d:\backup.
And inclusive mask, on the contrary, specifies which files should be processed:
nnbackup.exe -i c:\data -o d:\backup -m *.htm*
Explanation: Copy files with htm and html extension, and only these files, from c:\data to d:\backup.
Inclusive and exclusive masks can be used together.
Now let's discuss point #3. The simplest mask can be created by using the '*' symbol which is just a placeholder for zero or more characters. For example, the mask '*test' matches words 'test', 'contest', '123test', but not matches the words 'test123' and 'test_one'. On the other hand, the mask '*test*' matches all the words from the previous example and all the other words, which starts from 'test', include 'test' inside it or ends with 'test'.
Symbol '*' is not your only choice when creating masks. In your masks you can use so called regular expressions (regexps, REs) as well - a powerfull tool for creating templates which can be used for searching and comparing any symbols and strings (even the most complex) in a text. Regular expressions syntax is briefly described right there. All regexps should be enclosed between forward slashes (/.../) when using in masks.
nnbackup.exe -i c:\data -o d:\backup -m "/\d*\.htm/"
Explanation: Copy only the files with htm extension which name consists of numbers from c:\data to d:\backup.
Point #4. Several masks, separated by commas, can be used as an argument for options -m, -dm, -x and -dx in a command line:
nnbackup.exe -i c:\data -o d:\backup -m *.htm*,*.css,*.gif,*.jpeg
Explanation: Copy from c:\data to d:\backup files that have the following extensions: htm, html, css, gif and jpeg.
nnbackup.exe -i c:\data -o d:\backup -x *.txt,*.doc,*.rtf,*.pdf
Explanation: Copy from c:\data to d:\backup all files except those with extensions txt, doc, rtf and pdf.
Another type of argument that -m and -x can accept is a name of a text file containing a list of masks; each mask should be placed on a separate line. For example, we can create a text file doc.msk, containing the following lines:
*.txt
*.doc
*.rtf
Now this file's name can be used as an argument for options -m and -x:
nnbackup.exe -i c:\data -o d:\backup -m @doc.msk
Explanation: Copy from c:\data to d:\backup all files with extensions txt, doc, rtf and pdf.
nnbackup.exe -i c:\data -o d:\backup -x @doc.msk
Explanation: Copy from c:\data to d:\backup all files except those with extensions txt, doc, rtf and pdf.
nnBackup's capability to read masks from a text file can come very handy when you often have to use the same sets of masks or when a list of files to be processed is generated by a special exterior program.
Here is another example of a text file with masks; it contains masks for temporary files and indices as well as masks including subdirectories:
*.~* *.bkp *.bak
*.nsx *.ntx *.idx
*\temp*\* *\external*\*
Note, please, that you can use file names masks and directory names masks at the same time. This is very useful, for example, when you want to exclude one or several directories from file processing:
nnbackup.exe -i c:\data -o d:\backup -s -m *.htm -dx "wrong_*,*temp*"
Explanation: Copy all htm-files from c:\data directory and all it's subdirectories (except subfolders which name starts from 'wrong_' and subfolders which name include 'temp') into d:\backup.
And now the last point we mentioned, point #5: mask of a file/directory name may include not just a name of a file/directory, but it's relative path as well, which is counted off from the input directory. This makes working with masks a bit more complicated task, but gives a user additional strength in return. The rules are easy enough: if there is a symbol '\' (backslash) in the created mask, the mask is compared to the file/directory relative path. If there is no backslash in the mask - it is compared to file/directory name only.
The inclusion of the relative path into file/directory names masks allows to include in (or exclude of) processing entire subdirectories and the files they contain. For example, if directory ñ:\data has subdirectory named images, I can use the following mask:
nnbackup.exe -i c:\data -o d:\backup -m *.exe,*images\* -s
Explanation: Copy all executable files and all content of subdirectory images from c:\data and all its subdirectories to d:\backup.
When you include or exclude entire directories, it may be convenient to use both inclusive and exclusive masks at the same time. Let us modify the above example in such a way that files with bmp extension in subdirectory images are not copied:
nnbackup.exe -i c:\data -o d:\backup -m *.exe,*images\* -x *images\*.bmp -s
Explanation: Copy all executable files and all content of subdirectory images (except files with bmp extension) from c:\data and all its subdirectories to d:\backup.