how to delete a folder in databricks mnt?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2016 04:53 AM
I have a folder at location dbfs:/mnt/temp
I need to delete this folder. I tried using
%fs rm mnt/temp
&
dbutils.fs.rm("mnt/temp")
Could you please help me out with what I am doing wrong?
- Labels:
-
Folders
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2016 09:29 AM
Hi nmud19,
What error did you get? Can you paste a stack trace?
You may need to make the path absolute and set recursive to true.
dbutils.fs.rm("/mnt/temp", true)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017 02:38 PM
Or, to be more readable:
dbutils.fs.rm(fileprefix+".tmp",recurse=true)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 10:33 AM
dbutils.fs.rm("/mnt/temp",True)
The command above works in runtime 5.1 with python3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 04:15 PM
Since you're deleting a folder in the
/mnt directory, I assume it was made when you mounted a data source. If that's the case, you can delete the folder using
dbutils.fs.unmount("/mnt/temp/")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2019 01:18 AM
I found the easier way out. It was getting this error all the time: TypeError: '/mnt/adls2/demo/target/' has the wrong type - class bool is expected. Googling helped a lot 😉
Remove files from directory after uploading in Databricks using research paper help in copying files using dbutils
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2019 04:28 AM
try LongPathTool program
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 09:15 AM
how do I delete multiple folders within a mount point ???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2020 12:16 AM
use this (last raw should not be indented twice...):
def delete_mounted_dir(dirname):
files=dbutils.fs.ls(dirname)
for f in files:
if f.isDir():
delete_mounted_dir(f.path)
dbutils.fs.rm(f.path, recurse=True)