Extract metadata

Extract metadata

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.



Install the latest version of dotnet core.

MacOS & Linux

Install PowerShell. Run the pwsh command to test the installation.


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

PowerShell 7.2.5
Copyright (c) Microsoft Corporation.

Type 'help' to get help.
PS /Users/user/repos/boxcli/examples> 

If you encounter issues make sure you installed both dotnet core and PowerShell.

Box application

To use the script, you will need a Box application with OAuth 2.0 authentication. If you don't have one, go to your Developer Console, and follow the Setup with OAuth 2.0 guide.

Configure the script

  1. Clone the boxcli GitHub repository or download the files from examples directory.

    git clone https://github.com/box/boxcli.git
  2. Specify the folderID and userID parameters to tell the script which folder to scan, and who is the user running the script.

    [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:

    ./Metadata-extraction.ps1 -folderId 123456789 -userId 123456789

Run the script

  1. Change the directory to the folder containing the script. In this example, it is the Metadata Extraction folder.

    rvb@lab:~/box-cli/examples/Metadata Extraction$ pwsh
    PowerShell 7.2.4
    Copyright (c) Microsoft Corporation.
    Type 'help' to get help.
    PS /home/rvb/box-cli/examples/Metadata Extraction>
  2. Run the script.

    ./Metadata-extraction.ps1 -folderId 123456789 -userId 123456789

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

    Pulling data from Folder ID: 173961139760
    metadata as user ID: 20718545815
    Reading Item ID: 1016853559790
    Metadata saved to: MetadataTemplate_properties.csv


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.