cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How can I delete folders from my DBFS?

Mir_SakhawatHos
New Contributor II

I want to delete my created folder from DBFS. But how? How can I download files from there?

2 REPLIES 2

__max
New Contributor III

Hello,

Please, take a look at the documentation:

https://docs.databricks.com/user-guide/dbfs-databricks-file-system.html#dbfs-command-line-interface

To delete created folder in notebooks:

%fs rm -r foobar

To download files, please, use dbfs:

# Get dbfs:/apple.txt and save to local file ./apple.txt
dbfs cp -r dbfs:/src ./dst

The tool could be installed via:

pip install --upgrade databricks-cli

Best regards,

Maxim Gekk

IA
New Contributor II

Hello,

Max answer focuses on the CLI. Instead, using the Community Edition Platform, proceed as follows:

# You must first delete all files in your folder.

1. import org.apache.hadoop.fs.{Path, FileSystem}

 

2. dbutils.fs.rm("/FileStore/tables/file.csv")

You can refresh DBFS each time you proceed to action above for checking is the file was deleted.

When all files are deleted then you can delete the folder using the same command (2.).

Good luck.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group