Item

The Item object represents a file or folder displayed in a tab. You can obtain a collection of Item objects from the various methods of the Tab object. A collection of Item objects is also used with the Command object to specify the files or folders a command should operate on. Using the FSUtil.ReadDir method to enumerate the contents of a folder also returns an Item object.

 

Property Name

Return Type

Description

<default value>

string

Returns the full pathname of the item (i.e. path plus filename).

access

date

Returns the "last accessed" date, in local time.

access_utc

date

Returns the "last accessed" date, in UTC.

attr

int

Returns the item attributes. This value is a series of flags that are logically OR'd together. The attributes supported by Opus are:

1 - read only
2 - hidden
4 - system
32 - archive
2048 - compressed
4096 - offline storage
16384 - encrypted

attr_text

string

Returns the item attributes as a string, as displayed in the file display.

checked

bool

Returns True if the item was checked (in checkbox mode), or False otherwise.

create

date

Returns the "creation" date, in local time.

create_utc

date

Returns the "creation" date, in UTC.

display_name

string

Returns the display name of the item. Only a few items have a display name that is different to their actual name - some examples are certain system folders (like C:\Users which might have a translated display name in non-English locales).

ext

string

Returns the filename extension.

failed

bool

Returns True if the item failed when used by a command. This is only meaningful in conjunction with the Command.files collection - once the command has returned, this property will indicate success or failure on a per-file basis.

got_size

bool

Returns True for folder items if their size has been calculated by, for example, the GetSizes command. If False, the size property will be unreliable for folders.

groups

Vector:FiletypeGroup 

Returns a Vector of FiletypeGroup objects representing any and all file type groups that this file is a member of.

id

int

This is a unique ID for the item; it is used internally by Opus.

is_dir

bool

Returns True if the item represents a folder, and False for a file.

metadata

object:Metadata 

Returns a Metadata object that provides access to the item's metadata.

modify

date

Returns the "last modified" date, in local time.

modify_utc

date

Returns the "last modified" date, in UTC.

name

string

Returns the name of the item.

name_stem

string

Returns the filename "stem" of the item. This is the name of the item with the filename extension removed. It will be the same as the name for folders.

path

object:Path

Returns the path of the item's parent folder. This does not include the name of the item itself, which can be obtained via the name property.

realpath

object:Path

Returns the "real" path of the item. For items located in virtual folders like Libraries or Collections, this lets you access the item's underlying path in the real file system. The realpath property includes the full path to the item, including its own name.

selected

bool

Returns True if the item was selected, or False otherwise.

size

object:FileSize 

Returns the size of the item as a FileSize object.

 

Method Name

Arguments

Return Type

Description

Open

<string:path>
<string:mode>
<object:window>

object:File 

Opens this file and returns a File object that lets you access its contents as binary data.

By default the file will be opened in read mode - specify "w" for the optional mode parameter to open the file in write mode. Note that you cannot both read and write with the same File object.


When opening in write mode, you can also specify optional flags that control how the file is opened:

wc - create a new file, only if it doesn't already exist.
wa - create a new file, always. If the file already exists it will be overwritten. (this is the default)
we - open existing file. The file will not be created if it doesn't already exist.
wo - open existing file. If the file doesn't exist it will be created.
wt - truncate existing file. If the file exists it will be truncated. The file will not be created if it doesn't already exist.

If you only want to make changes to the file's attributes without modifying its data you can also specify "m" to open it in modify mode.

The optional window parameter lets you associate the File object with a Tab or a Lister, which will be used if Opus needs to display any dialogs (e.g. a UAC elevation dialog).