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

# Extract metadata

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

This script extracts metadata details for all the
files and folders in any Box folder and
saves the result in a CSV spreadsheet for
each metadata template.

## Prerequisites

### Windows

Install the latest version of [.NET core](https://dotnet.microsoft.com/download).

### macOS & Linux

Install [PowerShell][pwsh]. Run the `pwsh` command to test the installation.

```bash theme={null}
pwsh
```

Depending on the directory you are
running the command in, the output may differ.
For example:

```bash theme={null}
PowerShell 7.2.5
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /Users/user/repos/boxcli/examples>
```

<Info>
  If you encounter issues make sure you installed both
  [.NET core](https://dotnet.microsoft.com/download) and
  [PowerShell][pwsh].
</Info>

### Box CLI

To use the script, you need the Box CLI
installed and configured. You can do this by following
our <Link href="/guides/cli">quick start guide</Link>.

## Configure the script

1. Clone the `boxcli` GitHub repository and cd into this example's folder or download the files from the [`examples`][examples] directory.

   ```bash theme={null}
   git clone https://github.com/box/boxcli.git
   cd boxcli/examples/Metadata\ Extraction/
   ```

2. Specify the `folderID` and `userID` parameters to tell the script which folder to scan, and who is the user running the script.

   ```bash theme={null}
   [string]$FolderID = "",
   [string]$UserID = "",
   ```

   If you don't want to specify the parameters directly in the script,
   you can either pass them as flags or allow the script
   to prompt you to enter them. A sample command with flags looks as follows:

   ```bash theme={null}
   ./Metadata-extraction.ps1 -folderId 123456789 -userId 123456789
   ```

## Run the script

1. Run the Powershell command.

   ```bash theme={null}
   pwsh
   ```

2. Run the script.

   ```bash theme={null}
   ./Metadata-extraction.ps1 -folderId 123456789 -userId 123456789
   ```

   When the script finishes, you will see the following
   output or a similar one.

   ```bash theme={null}
   Pulling data from Folder ID: 173961139760
   metadata as user ID: 20718545815
   Reading Item ID: 1016853559790
   Metadata saved to: MetadataTemplate_properties.csv
   ```

## Logs

Logs are stored in a `logs` folder located in the main folder.
You have access to these log files:

* `Metadata-extraction_all.txt` that contains all log entries.
* `Metadata-extraction_errors.txt` that contains only errors.

[scripts]: https://github.com/box/boxcli/tree/main/examples

[pwsh]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.2

[console]: https://app.box.com/developers/console

[auth]: /guides/authentication/oauth2/oauth2-setup

[examples]: https://github.com/box/boxcli/tree/main/examples/Metadata%20Extraction

<RelatedLinks
  title="RELATED GUIDES"
  items={[
{ label: translate("OAuth 2.0 Auth"), href: "/guides/authentication/oauth2/index", badge: "GUIDE" },
{ label: translate("Using PowerShell Scripts with the Box CLI"), href: "/guides/cli/scripts/powershell-script-templates", badge: "GUIDE" }
]}
/>
