Delete folder using Databricks CLI

joaogilsa
Databricks Partner

Hello,

I am trying to delete a folder and its content using databricks cli, but I'm getting the following error:

databricks workspace delete /Workspace/Users/XXX/XXX --profile DEFAULT --recursive true
Error: expected to have the absolute path of the notebook or directory

I have tried deleting a single file, and it's working. It's only when I try to delete a folder that it fails.

Thank you in advance!

szymon_dybczak
Esteemed Contributor III

Hi @joaogilsa ,

Delete true after recursive and it should work 😀 Look at below help output. It looks like that recursive it's already boolean flag, so when you add true I think it has problem with parsing:

Delete a workspace object.
  
  Deletes an object or a directory (and optionally recursively deletes all
  objects in the directory). * If path does not exist, this call returns an
  error RESOURCE_DOES_NOT_EXIST. * If path is a non-empty directory and
  recursive is set to false, this call returns an error
  DIRECTORY_NOT_EMPTY.
  
  Object deletion cannot be undone and deleting a directory recursively is not
  atomic.

  Arguments:
    PATH: The absolute path of the notebook or directory.

Usage:
  databricks workspace delete PATH [flags]

Flags:
  -h, --help        help for delete
      --json JSON   either inline JSON string or @path/to/file.json with request body (default JSON (0 bytes))
      --recursive   The flag that specifies whether to delete the object recursively.

View solution in original post

joaogilsa
Databricks Partner

Thank you for the help, @szymon_dybczak, it worked!

szymon_dybczak
Esteemed Contributor III

Cool, glad that it worked 🙂