> ## 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.

# メタデータの抽出

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>;
};

このスクリプトでは、任意のBoxフォルダ内のすべてのファイルとフォルダのメタデータの詳細を抽出し、その結果を各メタデータテンプレートのCSVスプレッドシートに保存します。

## 前提条件

### Windows

[.NET Core](https://dotnet.microsoft.com/download)の最新バージョンのインストール

### macOSおよびLinux

[PowerShell][pwsh]をインストールします。`pwsh`コマンドを実行して、インストール結果をテストします。

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

どのディレクトリでこのコマンドを実行するかに応じて、出力が異なる場合があります。以下に例を示します。

```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>
  問題が発生する場合は、[.NET Core](https://dotnet.microsoft.com/download)と[PowerShell][pwsh]の両方をインストールしたかどうか確認してください。
</Info>

### Box CLI

スクリプトを使用するには、Box CLIをインストールし、構成する必要があります。これを実行するには、<Link href="/guides/cli">クイックスタートガイド</Link>の手順に従います。

## スクリプトの構成

1. `boxcli` GitHubリポジトリを複製してこの例のフォルダにcdコマンドで移動するか、[`examples`][examples]ディレクトリからファイルをダウンロードします。

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

2. `folderID`および`userID`パラメータを指定して、スキャンするフォルダとスクリプトを実行するユーザーをスクリプトに指示します。

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

   パラメータをスクリプトで直接指定しない場合は、フラグとして渡すか、スクリプトで入力を求めるプロンプトを表示することができます。フラグを使用したコマンドのサンプルは次のようになります。

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

## スクリプトの実行

1. PowerShellコマンドを実行します。

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

2. スクリプトを実行します。

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

   スクリプトが終了すると、以下のような出力が表示されます。

   ```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`フォルダに格納されます。以下のログファイルにアクセスできます。

* `Metadata-extraction_all.txt`: すべてのログエントリが含まれています。
* `Metadata-extraction_errors.txt`: エラーのみが含まれています。

[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="関連するガイド"
  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" }
]}
/>
