Deleting Box Folder using Box Folder Id
Hi,
I want to delete the Box folders in Bulk and I have an excel sheet with box folder ids.
How can I delete the box folders in bulk using the box folder Id?
-
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 deletedand 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 Cand 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 CNow 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.
Please sign in to leave a comment.
Comments
1 comment