Bulk Commands
You can use a CSV file to execute commands in bulk. Each row of the
spreadsheet is treated as an individual API call.
To execute a bulk command, use the option --bulk-file-path=<PATH_TO_CSV>, where
<PATH_TO_CSV> is the local path of a CSV file containing the
necessary information.
For example, you can create folders using the command box folders:create --bulk-file-path=path/to/file.csv
Drag the CSV file from your finder window/file explorer to the
terminal/command line window to auto-populate the path.
To specify the column names for your CSV file, go to the GitHub repository and look at the argument names, or use the --help option. In this
case, these are PARENTID and NAME and are case insensitive.
You can also use a CSV
template for this example bulk create folders command.
Executing the command below creates three folders at the root level, 0, of the
Service Account’s folder tree.
box folders:create --bulk-file-path=/Users/ExampleUser/Desktop/bulkcreatefolders.csv
Set up and use bulk commands
-
Clone the
boxcli GitHub repository or download the files from Bulk actions directory.
git clone https://github.com/box/boxcli.git
-
Adjust the
.csv template to your needs. For example, if you want to create several folders, you can use the folders-create.csv template as your starting point.
-
Run the command.
box folders:create --bulk-file-path <PATH_TO_CSV>/folders-create.csv
Bulk Commands with Options
Any option included in the command is applied to every row in the CSV file. For example,
box folders:collaborations:create --bulk-file-path=path/to/file.csv --role=editor
will create collaborations for each user in the csv as an editor.
However, you can also use options in the CSV file. Building on the last example,
instead of using the --role=editor option in the command itself, it can be a
column called role. The command becomes:
box folders:collaborations:create --bulk-file-path=pathtocsv
CSV templates
Predefined CSV templates help you to structure the data you want to manage in bulk. Templates reside in the Bulk actions directory, grouped into folders. The table below lists the currently available templates.
| Templates | Description |
|---|
| box collaborations | Create, delete, and update collaborations. |
| box files | Download, update, and upload files. |
| box folders | Create and update folders, add metadata to folders. |
| box groups | Create groups and add memberships. |
| box metadata-templates | Create metadata templates and metadata cascade policies on folders. |
| box shared-links | Delete shared links. |
| box users | Create and update users, move one user’s content to another user. |
| box webhooks | Delete webhooks. |