Deleting Box Folder using Box Folder Id

New post

Comments

1 comment

  • Rui Barbosa

    Hi Syed,

    Sounds like the Box CLI is you best bet to accomplish this.

    First I'm going to create a folder with folders to be deleted. I recommend you try this before actually implement it so you get familiar with the procedure.

    ❯ box folders:create 0 "Folders to be deleted" --csv --fields type,id,name
    ### output ###
    type,id,name
    folder,198776374510,Folders to be deleted

    and then a few more inside the newly created folder:

    ❯ box folders:create 198776374510  "TBD A"
    ❯ box folders:create 198776374510  "TBD B"
    ❯ box folders:create 198776374510  "TBD C"

    and lets list them and create an .CSV file:

    ❯ box folders:items 198776374510 --csv --fields type,id,name
    type,id,name
    folder,198778469597,TBD A
    folder,198777993773,TBD B
    folder,198776218183,TBD C

    and create a .CSV file:

    ❯ box folders:items 198776374510 --csv --fields type,id,name > folders_to_delete.csv

    which look like:

    ❯ cat folders_to_delete.csv
    type,id,name
    folder,198778469597,TBD A
    folder,198777993773,TBD B
    folder,198776218183,TBD C

    Now we can just use the .CSV file to delete the folders in bulk:

    ❯ box folders:delete --bulk-file-path ./folders_to_delete.csv
    [----------------------------------------] 0% | 0/3Deleted folder 198781373383
    [=============---------------------------] 33% | 1/3Deleted folder 198777694297
    [===========================-------------] 67% | 2/3Deleted folder 198780128173
    [========================================] 100% | 3/3

    All bulk input entries processed successfully.

    Note that this sample only had folders inside, you must filter your CSV to only contain folder id's, otherwise the bulk delete will throw an error.

    You should be able to export your excel file into a CSV, make sure that at least the id header and column are present.

    0
    Comment actions Permalink

Please sign in to leave a comment.