> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ppio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get file and directory metadata

> Get the name, type, path, size, permissions, owner, group and modified time of a file or directory in a sandbox with get_info() or getInfo().

The `files` module returns an entry object for a path in the sandbox, whether the path is a file or a directory. The object lists the filename, type and path, along with the size, permissions and owner recorded by the filesystem.

> [!NOTE]
>
> Install the SDK, or the CLI for `ppio` commands, and set the `PPIO_API_KEY` and `PPIO_DOMAIN` environment variables before running these examples. See [Quickstart](https://docs.ppio.ai/sandbox/quickstart.md) and [Install and authenticate](https://docs.ppio.ai/sandbox/cli/install.md).

## Get metadata about a file

Create a file, then pass its path to `get_info()` or `getInfo()`.

```python Python theme={null}
from ppio_sandbox import PPIO

ppio = PPIO()
sandbox = ppio.code_interpreter.create()

# Create test file
file_path_in_sandbox = '/tmp/test-file'
sandbox.files.write(file_path_in_sandbox, 'test-file-content')

# Get file metadata
info = sandbox.files.get_info(file_path_in_sandbox)
print(info)

sandbox.kill()
```

```javascript Node.js theme={null}
// index.mts
import { PPIO } from 'ppio-sandbox'

const ppio = new PPIO()
const sandbox = await ppio.codeInterpreter.create()

// Create test file
const filePathInSandbox = '/tmp/test-file'
await sandbox.files.write(filePathInSandbox, 'test-file-content')

// Get file metadata
const info = await sandbox.files.getInfo(filePathInSandbox)
console.log(info)

await sandbox.kill()
```

## Get metadata about a directory

The same call returns metadata for a directory, with `type` set to `dir`.

```python Python theme={null}
from ppio_sandbox import PPIO

ppio = PPIO()
sandbox = ppio.code_interpreter.create()

# Create test directory
dir_path_in_sandbox = '/tmp/test-dir'
sandbox.files.make_dir(dir_path_in_sandbox)

# Get directory metadata
info = sandbox.files.get_info(dir_path_in_sandbox)
print(info)

sandbox.kill()
```

```javascript Node.js theme={null}
// index.mts
import { PPIO } from 'ppio-sandbox'

const ppio = new PPIO()
const sandbox = await ppio.codeInterpreter.create()

// Create test directory
const dirPathInSandbox = '/tmp/test-dir'
await sandbox.files.makeDir(dirPathInSandbox)

// Get directory metadata
const info = await sandbox.files.getInfo(dirPathInSandbox)
console.log(info)

await sandbox.kill()
```

## Metadata fields

The entry object has the following fields.

> [tab] Python
>
> **name** `string`
>
> Name of the file or directory, without the parent path.
>
> **type** `FileType`
>
> `FileType.FILE` (value `file`) for a file and `FileType.DIR` (value `dir`) for a directory.
>
> **path** `string`
>
> Full path of the entry inside the sandbox.
>
> **size** `number`
>
> Size in bytes.
>
> **mode** `number`
>
> Numeric mode, such as `420` for a file with `-rw-r--r--` permissions.
>
> **permissions** `string`
>
> Symbolic permissions, such as `-rw-r--r--` for a file or `drwxr-xr-x` for a directory.
>
> **owner** `string`
>
> Owner of the entry.
>
> **group** `string`
>
> Group of the entry.
>
> **modified\_time** `datetime`
>
> Last modification time.
>
> **symlink\_target** `string | null`
>
> Target of the entry when it is a symbolic link, otherwise `None`.

> [tab] Node.js
>
> **name** `string`
>
> Name of the file or directory, without the parent path.
>
> **type** `FileType`
>
> `FileType.FILE` (value `file`) for a file and `FileType.DIR` (value `dir`) for a directory.
>
> **path** `string`
>
> Full path of the entry inside the sandbox.
>
> **size** `number`
>
> Size in bytes.
>
> **mode** `number`
>
> Numeric mode, such as `420` for a file with `-rw-r--r--` permissions.
>
> **permissions** `string`
>
> Symbolic permissions, such as `-rw-r--r--` for a file or `drwxr-xr-x` for a directory.
>
> **owner** `string`
>
> Owner of the entry.
>
> **group** `string`
>
> Group of the entry.
>
> **modifiedTime** `Date`
>
> Last modification time.
>
> **symlinkTarget** `string`
>
> Target of the entry when it is a symbolic link, otherwise `undefined`.


## Related topics

- [Work with files in a sandbox](https://docs.ppio.ai/sandbox/filesystem/overview.md)
- [Watch a directory for changes](https://docs.ppio.ai/sandbox/filesystem/watch.md)
- [Upload files to a sandbox](https://docs.ppio.ai/sandbox/filesystem/upload.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.