Box: Delete Folder
Delete folders on Box. You can delete multiple folders at once. When you delete multiple ones, you should write one folder ID on each line.
  • C1: OAuth2 Setting *
  • C2: Data Item with Folder IDs to delete *
Script (click to open)

function main(){
  const folderIds = engine.findDataByNumber(configs.get("FolderIdsItem"));
  if (folderIds === "" ||folderIds === null){
    throw "Folder IDs aren't set.";

  let linesArray = folderIds.split("\n");
  linesArray = linesArray.filter(lines => lines !== ""); // 空文字列を削除
  if (linesArray.length === 0) {
    throw "Folder IDs aren't set.";

  const numOfLines = linesArray.length;
  if (numOfLines > httpClient.getRequestingLimit()){
  	throw "Number of Folder IDs is over the limit."
  const oauth2 = configs.get("OAuth2");
  for (let i = 0; i < numOfLines; i++){
    deleteFolder(oauth2, linesArray[i])

function deleteFolder(oauth2, folderId) {
  const url = `${folderId}`;

  let response = httpClient.begin()
  const status = response.getStatusCode();
  const responseTxt = response.getResponseAsString();
  engine.log(`status: ${status}`);
  if (status >= 300) {
    throw `Failed to delete Folder ID:${folderId}`;
    engine.log(`Succeeded to delete Folder ID:${folderId}`);


2021-03-26 (C) Questetra, Inc. (MIT License)
The Addon-import feature is available with Professional or Enterprise edition.


  1. Folder ID is contained in the URL: https://{sub-domain} ID)
  2. The refresh token for Box has the expiration. Use regularly to ensure that it does not exceed the expiration. (Box: Token & URL Expiration)


See also

%d bloggers like this: