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

# メタデータの抽出

このスクリプトでは、任意の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>
```

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

### Box CLI

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

## スクリプトの構成

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]: https://developer.box.com/guides/authentication/oauth2/oauth2-setup.md

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

**関連するガイド**
