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?
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)
07-27-2017 02:38 PM
Or, to be more readable:
dbutils.fs.rm(fileprefix+".tmp",recurse=true)
02-14-2019 10:33 AM
dbutils.fs.rm("/mnt/temp",True)
The command above works in runtime 5.1 with python3
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/")
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
12-08-2019 04:28 AM
try LongPathTool program
10-28-2020 09:15 AM
how do I delete multiple folders within a mount point ???
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)
Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections.
Click here to register and join today!
Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.