Get file directory info
  • 18 May 2022
  • 1 Minute to read
  • Dark
    Light
  • PDF

Get file directory info

  • Dark
    Light
  • PDF

Article Summary

Given a local filesystem path, get information about the file/directory it points to.

Since a path can be either a file or a directory, the Type output argument resolves to either file or directory.

Correspondingly, File or Directory will be a null value.

Input arguments

LabelKeyTypeRequired?DefaultDescription
File pathpathString(local-filesystem-reference)YesAbsolute local filesystem path to a file/directory.

Output arguments

Number of outputs: 2

LabelKeyTypeDescription
TypetypeStringType of item at the given path
FilefileObjectObject describing the file at the given path, if found.
  • Local path
file.pathStringAbsolute local filesystem path representing the file location on the device, including the filename and extension. On web, this is created via the [`createObjectURL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) method.
  • MIME type
file.mimeTypeStringMIME type of the file, if it could be determined.
  • Name
file.nameStringName of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already.
  • Size
file.sizeNumberSize of the file, in bytes.
  • Created at
file.createdAtStringCreation datetime of the file, if it can be determined.
  • Modified at
file.modifiedAtStringDatetime when the file was last modified, if it can be determined.
DirectorydirectoryObjectObject describing the directory at the given path, if found.
  • Local path
directory.pathStringAbsolute local filesystem path representing the directory location on the device.
  • Name
directory.nameStringName of the directory in the local filesystem, if applicable. Note that the directory name is included in the **Local path** property.
  • Files in directory
directory.filesArrayList of objects representing the files in the directory.
  • Subdirectories
directory.directoriesArrayList of objects describing subdirectories of the directory.
  • Total size
directory.totalSizeNumberTotal size of the directory, in bytes.

Events

No events.

Errors

LabelCodeDescription
File/directory not foundfileNotFoundThrown if a file/directory could not be found at the given path.

Was this article helpful?