sort on

Synopsis

sort on <property-list>

Description

Controls the order in which some algorithms will attempt to arrange files on the disk. The following properties are supported:

Property Description Can compare with
name The name of the file. A string or regular expression
id The catalog node ID of the file. A number
size The size of the file; this uses the size of the data fork, if present, or the resource fork otherwise. A number
creator The four character creator code for this file. A number, string or regular expression
type The four character type code for this file. A number, string or regular expression
content modification date The last time at which the file was modified. A string or number of seconds since 1970
attribute modification date The last time at which the file’s attributes were modified. A string or number of seconds since 1970
access date The last time at which the file was accessed. A string or number of seconds since 1970
creation date The time at which the file was created. A string or number of seconds since 1970
backup date The time at which the file was backed-up. A string or number of seconds since 1970
owner The UID of the owner of the file. A number
group The GID of the group of the file. A number
mode The file’s UNIX mode. A number
admin flags The file’s administrative flags. A number
owner flags The file’s owner-specific flags. A number
resource fork size The total size of the file’s resource fork. A number
data fork size The total size of the file’s data fork. A number
containing folder The folder immediately containing the file (for sorting, this property refers to the catalog node ID of the containing folder, not the name). A string, regular expression, or the catalog ID of the folder

By default, sort on will sort in ascending order; if you want to sort a particular property in descending order instead, you can prefix its name with a - sign.

Example

// Sort application files into some sort of order

class "Applications" {
  match files where file is within "/Applications"
  color "#ffff00"
  sort on containing folder, name
}

// Sort documents by descending date (i.e. newest first)

class "Documents" {
  match files where file is within "/Users/bob/Documents"
  color "#00ffff"
  sort on -creation date
}

See also

class