Glindra
Documentation Index Download
Command Line File Handling and ASCII Tools

File Selection Options

Example (Windows)
> d *** -exclude=(.doc .txt) -before=today -min_size=2mb -hidden=also
Example (Linux)
> d '***' -exclude=\(.doc .txt\) -before=today -min_size=2mb -hidden=also
Options
-since [= datetime] Select files that were created on or after a certain date/time.
-before [= datetime] Select file that were created before a certain date/time.
-min_size [= size] Specify a minimum file size in bytes, Mb, or some other unit
-max_size [= size] Specify a maximum file size .
-directories [= only/also/not]
List directory files (only/also/not) .
-hidden [= only/also/not] List hidden files (only/also/not).
-nodefault Do not add any default wildcards or other filename parts to the filename.
-exclude [= filespec] Exclude files that match the file specification given as option value. If the option value is enclosed in parenthesis, it can contain a full file specification, including recursive file selection options.
-current_only List only the current version of the files by default. This option can be overridden by the file specification and/or the -default option. The -current option is specific to the d directory command.

Introduction

All of the file selection options have the effect of limiting the selection of files in one way or another. They are intended to be used together with some wildcard file specification.

For example,

> d '*.*' -since=today
lists all files in the current directory that have been created since 00:00h today. If we only wanted to see files that were created today and had the extension .xyz, we would write
> d '*.xyz' -since=today

If more than one of these options is given, the only files that will be selected are those that fulfill all the criteria. This means that
> d '*.*' -since=1-may -before=1-jun
will only list the files that were created some time during the month of May (in the current year), since each file has to be created after 00:00h on May 1 and before 00:00h on June 1.

The file selection options are part of the general definition of a file specification. This means that they are available in all Glindra programs, and not just in the basic file handling programs d (directory), cop (copy), rena (rename), dele (delete), and pu (purge).

-since [= datetime]
-before [= datetime]

Example (Windows)
> d -since=(1-may 18:00)
> d -before=yesterday


These options let you select files based on the date and time when they were created or modified. The selection is done on the "modified" date/time field of the files.

The -before and -since options accept a date, a time, or both, as the option value.

-before selects files that were modified before a certain date/time.

-since selects files that were modified on or after a certain date/time.


If you specify either of these options but do not give a date/time value, the default value is today. This is shorthand for 00:00 hours on the current day, so -before (without a date/time value) will exclude all of today's files, and -since will list only today's files.

The selection is done on the "modified" date/time of the files.

-min_size [= size]
-max_size [= size]

With these options, you can limit the selection of files to those that have a certain size.

Example
> d '***' -min_size=3.5mb
Byte size units

File sizes can be specified either as a plain number, or with one of the following size units:

Keyword Description

byte Bytes
kb kilobyte Kilobyte = 1,000 bytes
mb megabyte Megabyte = 1,000,000 bytes
gb gigabyte Gigabyte = 1,000,000,000 bytes
tb terabyte Terabyte = 1,000,000,000,000 bytes
pb petabyte Petabyte = 1,000,000,000,000,000 bytes
eb exabyte Exabyte = 1,000,000,000,000,000,000 bytes

The default, if you do not specify any unit, is bytes. The unit keywords may be abbreviated as long as they are unique.

Note that the size units have their proper scientific base 10 meanings, so that a kilobyte is 1000 bytes, and not 1024 bytes. For example, you could specify -min_size=10mb to get only files that have a size of 10,000,000 bytes or more.

There must be at least one digit before the size unit, so 1 megabyte is written as 1mb. If you want to insert a space between the number and the size unit, you must enclose the value in parentheses, like -min_size=(17 kb).

See Parsing Byte Sizes for further discussion.

-directories [= only/also/not]

Specifies if directory files should be included in the list. The default, if the option is not present, is to list both directory files and ordinary files. You can override this, and have the program list only directory files, or to omit the directory files altogether, and only list regular files.

The option can take one of three values: only, also, or not.
default For d (directory), rena (rename), and dele (delete), the default is to list both directory files and regular files. This is the same as -directories=also
For cop (copy), pu (purge), and most other programs, the default is -nodirectories
-directories List directory files only. Same as -directories=only
-nodirectories List regular files only. Same as -directories=not
-directories=only List directory files only.
-directories=also List both directory files and regular files.
-directories=not List regular files only.

-hidden [= only/also/not]

List hidden files (only/also/not).

Specifies if hidden files should be included in the list. The default, if the option is not present, is to list both hidden files and ordinary files. You can override this, and have the program list only hidden files, or to omit the hidden files altogether, and only list regular files.

The option can take one of three values: only, also, or not, just like the -directories option described above. Note, however, that the defaults are different for the -hidden option.
default Do not list hidden files, but regular files only. Same as -hidden=not
-hidden List both hidden files and regular files. Same as -hidden=also
-nohidden Do not list hidden files, but regular files only. Same as -hidden=not, which is also the default.
-hidden=only List hidden files only.
-hidden=also List both hidden files and regular files.
-hidden=not Do not list hidden files, but regular files only.


-by_owner = owner

Select only files that are owned by owner.

Not yet implemented.

-nodefault

Do not add any default wildcards or other filename parts to the filename. If you specify this option, it will apply to both the input and output file specifications.

 You can override this by specifying the option -nodefault.

Input file specification

The d directory command adds the default wildcards *.*.* to the input file specification. If we leave the short name blank, it will be defaulted to a wildcard *. This presents a problem if we only want to see files that actually start with a dot:

> d .emacs

Directory of e:\system\init\

23 kb 30-Jun-2004 23:55:42 .emacs
19 kb 1-Nov-2004 21:12:07 junk.emacs
22 kb 13-Jun-2002 12:09:40 original.emacs
----------
63 kb total, 3 files

Because the wildcard is added automatically, we get the same file listing we would get with d *.emacs.

By adding the -nodefault option, we get just the file with nothing before the first dot:

> d .emacs -nodefault

Directory of e:\system\init\

23 kb 30-Jun-2004 23:55:42 .emacs
----------
23 kb total, 1 file


Output file specification

We get a similar problem if we try to copy or rename a file, to give it a name that starts with a dot.

Example
> rena original.emacs .emacs
No files renamed

The message "No files renamed" tells the truth, because with the defaults added, the output file name is the same as the input.

To solve this, we add the -nodefault option to the command line:

> rena original.emacs .emacs -nodefault
1 file renamed

> d *.emacs

Directory of e:\system\init\

22 kb 13-Jun-2002 12:09:40 .emacs
23 kb 30-Jun-2004 23:55:42 .emacs.~1~
19 kb 1-Nov-2004 21:12:07 junk.emacs
----------
63 kb total, 3 files

-exclude [= filespec]

Exclude all files that match the file specification filespec.

Example
> d 'abc*.*' -exclude='*.tmp'
Lists all files that have a name that begins with abc, except those that have the extension .tmp.


If it is enclosed in parentheses, the -exclude file specification can itself be arbitrarily complex, and may include its own file selection options.

Example (Windows)
-exclude = (*.tmp *.xyz -since)
excludes all files that have the extension .tmp or .xyz, and have been created or modified today.

-current_only

Example
> d -current

List only the current version of the files by default.


The primary purpose of this option is to make it possible to define an alias that The option can be overridden by the file specification and/or the -default option.

Example (Linux)
If we have defined the alias
> alias dc='d -current'
we can write
> dc
to get the latest version of all files in the directory, or
> dc '*.xyz'
to get the latest version of all files with the extension .xyz.


The -current option is specific to the d directory command. It would not be very meaningful in other programs, since the default for other programs would be the current version anyway.