# Get information about a file or directory (/docs/volumes/info)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 1681 · updated: 2026-07-30 -->
Related: [Download data from volume](/docs/volumes/download.md), [Managing volumes](/docs/volumes/manage.md), [Migrating data between volumes](/docs/volumes/migrate.md), [Mounting volumes](/docs/volumes/mount.md), [Read & write files](/docs/volumes/read-write.md), [Upload data to volume](/docs/volumes/upload.md)

You can get information about a file or directory in a volume using the `getInfo()` / `get_info()` method.

### Getting information about a file [#getting-information-about-a-file]

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```js  
      import { Volume } from 'e2b'

      const volume = await Volume.create('my-volume')

      // Create a new file
      await volume.writeFile('/test_file.txt', 'Hello, world!')

      // Get information about the file
      const info = await volume.getInfo('/test_file.txt')

      console.log(info)
      // {
      //   name: 'test_file.txt',
      //   type: 'file',
      //   path: '/test_file.txt',
      //   size: 13,
      //   mode: 0o644,
      //   uid: 0,
      //   gid: 0,
      //   atime: 2025-05-26T12:00:00.000Z,
      //   mtime: 2025-05-26T12:00:00.000Z,
      //   ctime: 2025-05-26T12:00:00.000Z,
      // }
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Volume

      volume = Volume.create('my-volume')

      # Create a new file
      volume.write_file('/test_file.txt', 'Hello, world!')

      # Get information about the file
      info = volume.get_info('/test_file.txt')

      print(info)
      # VolumeEntryStat(
      #   name='test_file.txt',
      #   type_='file',
      #   path='/test_file.txt',
      #   size=13,
      #   mode=0o644,
      #   uid=0,
      #   gid=0,
      #   atime=datetime(2025, 5, 26, 12, 0, 0),
      #   mtime=datetime(2025, 5, 26, 12, 0, 0),
      #   ctime=datetime(2025, 5, 26, 12, 0, 0),
      # )
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

### Getting information about a directory [#getting-information-about-a-directory]

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```js  
      import { Volume } from 'e2b'

      const volume = await Volume.create('my-volume')

      // Create a new directory
      await volume.makeDir('/test_dir')

      // Get information about the directory
      const info = await volume.getInfo('/test_dir')

      console.log(info)
      // {
      //   name: 'test_dir',
      //   type: 'directory',
      //   path: '/test_dir',
      //   size: 0,
      //   mode: 0o755,
      //   uid: 0,
      //   gid: 0,
      //   atime: 2025-05-26T12:00:00.000Z,
      //   mtime: 2025-05-26T12:00:00.000Z,
      //   ctime: 2025-05-26T12:00:00.000Z,
      // }
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Volume

      volume = Volume.create('my-volume')

      # Create a new directory
      volume.make_dir('/test_dir')

      # Get information about the directory
      info = volume.get_info('/test_dir')

      print(info)
      # VolumeEntryStat(
      #   name='test_dir',
      #   type_='directory',
      #   path='/test_dir',
      #   size=0,
      #   mode=0o755,
      #   uid=0,
      #   gid=0,
      #   atime=datetime(2025, 5, 26, 12, 0, 0),
      #   mtime=datetime(2025, 5, 26, 12, 0, 0),
      #   ctime=datetime(2025, 5, 26, 12, 0, 0),
      # )
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

### Checking if a path exists [#checking-if-a-path-exists]

You can check whether a file or directory exists in a volume using the `exists()` method.

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```js  
      import { Volume } from 'e2b'

      const volume = await Volume.create('my-volume')

      const fileExists = await volume.exists('/test_file.txt')
      console.log(fileExists) // true or false
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Volume

      volume = Volume.create('my-volume')

      file_exists = volume.exists('/test_file.txt')
      print(file_exists)  # True or False
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

### Updating metadata [#updating-metadata]

You can update file or directory metadata such as user ID, group ID, and permissions mode using the `updateMetadata()` / `update_metadata()` method.

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```js  
      import { Volume } from 'e2b'

      const volume = await Volume.create('my-volume')

      await volume.writeFile('/test_file.txt', 'Hello, world!')

      const updated = await volume.updateMetadata('/test_file.txt', { uid: 1000, gid: 1000, mode: 0o600 })

      console.log(updated)
      // {
      //   name: 'test_file.txt',
      //   type: 'file',
      //   path: '/test_file.txt',
      //   size: 13,
      //   mode: 0o600,
      //   uid: 1000,
      //   gid: 1000,
      //   ...
      // }
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Volume

      volume = Volume.create('my-volume')

      volume.write_file('/test_file.txt', 'Hello, world!')

      updated = volume.update_metadata('/test_file.txt', uid=1000, gid=1000, mode=0o600)

      print(updated)
      # VolumeEntryStat(
      #   name='test_file.txt',
      #   type_='file',
      #   path='/test_file.txt',
      #   size=13,
      #   mode=0o600,
      #   uid=1000,
      #   gid=1000,
      #   ...
      # )
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>
