Welcome to the new Box Support website. Check out all the details here on what’s changed.

Renaming multiple folders easily

New post

Comments

3 comments

  • Kourtney

    This can be done by creating a script using our API. The specific endpoint you would need to update the name would be: https://developer.box.com/reference#update-information-about-a-folder. However, you would first need to find all the folder IDs of the folders with the same name. Perhaps someone else might be able to provide more details on that piece!

     

    Best of luck,

    Kourtney  

    0
    Comment actions Permalink
  • jeevan1

    Thanks, I was looking for a way to do it in apex. I have box integrated on salesforce. 

     

    // Instantiate the Toolkit object
    box.Toolkit toolkit = new box.Toolkit();
    // Get the Salesforce record id associated with a Box folder
    String recordId = toolkit.getRecordIdByFolderId('{some folder id}');
    //folderNameOverride('some name');
    Http http = new Http();
    HttpRequest request = new HttpRequest();
    request.setEndpoint('https://developer.box.com/v2.0/reference#folder-object' + id);
    request.setMethod('PUT');
    request.setHeader('X-HTTP-Method-Override','PATCH');
            request.setTimeout(6000);
            HttpResponse response = http.send(request);

     

    0
    Comment actions Permalink
  • rocks101

    Have you had a look at the Box Salesforce SDK?

    - rename a folder

     

    BoxFolder folder = new BoxFolder(api, 'folder-id');
    folder.rename('New Name');

     

     

    ....or you can update the information for a folder as below:

     

    BoxFolder folder = new BoxFolder(api, 'folder-id');
    BoxFolder.Info info = folder.new Info();
    info.addValue('description', 'Some folder I made');
    info.addValue('name', 'New Folder Name');
    folder.updateFolderInfo(info);

     

     

    As  mentioned you will need to first get the folder Ids of all of the folders to be renamed

     

    BoxFolder folder = new BoxFolder(api, 'folder-id');
    list children = folder.getChildren();
    for (BoxItem.Info itemInfo : children) {
        if (itemInfo.getObjectType() == 'folder') {
            // Do something with the folder
        } else if (itemInfo.getObjectType() == 'file') {
            // Do something with the file
        }
    }

     

     * Note: A call to getChildren() will return the contents of a BoxFolder. Optionally, an offset and limit can be set to iterate over a large folder. Large folder operations will likely fail due to governor limits on callouts or heap size. This method could be detrimental depending on your use case 

    0
    Comment actions Permalink

Please sign in to leave a comment.