ScriptForge.FileSystem service

The FileSystem service includes routines to handle files and folders. Next are some examples of the features provided by this service:

note

The methods in the FileSystem service are mostly based on the XSimpleFileAccess UNO interface.


Definitions

The table below lists the main parameters used by most of the methods in the FileSystem service.

Parameter

Description

FileName

The full name of the file including the path without a path separator at the end.

FolderName

The full name of the folder including the path. It may or may not contain the ending path separator.

Name

The last component of the Folder Name or File Name including its extension. This parameter is always expressed using the native format of the operating system.

BaseName

The last component of the Folder Name or File Name without its extension.

NamePattern

Any of the above names containing wildcards in its last component. Admitted wildcards are:

  • "?" represents any single character

  • "*" represents zero, one, or multiple characters


tip

The FileSystem service allows to perform operations over multiple files at the same time. By using name patterns, user scripts can copy, move or delete multiple files. Conversely, Basic built-in methods can only handle single files.


File Naming Notation

The notation used to express file and folder names, both for arguments and returned values, is defined by the FileNaming property of the FileSystem service.

In short, the possible representation types are "URL" (URL file notation), "SYS" (operating system notation) and "ANY" (default). See more information below.

tip

An example of the URL notation is file:///C:/Documents/my_file.odt. Whenever possible consider using the URL notation because it is a more portable alternative.


warning

The use of the shortcut "~" (tilde), which is common in Linux-based operating systems, is not supported to express a path to a folder and file name. Instead of using "~/Documents/my_file.odt" use the full path "/home/user/Documents/my_file.odt".


Service invocation

The following code snippet invokes the FileSystem service. The method BuildPath was used as an example.

In Basic

      GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
      Dim FSO As Object
      Set FSO = CreateScriptService("FileSystem")
      FSO.BuildPath(...)
    
In Python

      from scriptforge import CreateScriptService
      fs = CreateScriptService("FileSystem")
      fs.BuildPath(...)
    

Properties

Name

Readonly

Type

Description

FileNaming

No

String

Sets or returns the current files and folders notation, either "ANY", "URL" or "SYS":

  • "ANY": (default) the methods of the FileSystem service accept both URL and current operating system's notation for input arguments but always return URL strings.

  • "URL": the methods of the FileSystem service expect URL notation for input arguments and return URL strings.

  • "SYS": the methods of the FileSystem service expect current operating system's notation for both input arguments and return strings.

Once set, the FileNaming property remains unchanged either until the end of the LibreOffice session or until it is set again.

ConfigFolder

Yes

String

Returns the configuration folder of LibreOffice.

ExtensionsFolder

Yes

String

Returns the folder where extensions are installed.

HomeFolder

Yes