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: 

Unable to delete a DBFS folder

wyzer
Contributor II

Hello everyone,

I've created by error a DBFS folder named : ${env]

But when I run this command :

dbutils.fs.rm("/mnt/${env]")

It returns me this error :

java.net.URISyntaxException: Illegal character in path at index 12: /mnt/$%7Benv]

How can I do please ?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

User16764241763
Honored Contributor

Hello @Salah K.​ 

Can you try below?

%sh rm -r /dbfs/mnt/$\{env\]

View solution in original post

4 REPLIES 4

Prabakar
Esteemed Contributor III
Esteemed Contributor III

hi @Salah K.​ what command you used to create the folder name $[env] ?

If you have used dbutils, it would have failed to create a folder with this name. You would have got the error "Illegal character in path".

Please do `%fs ls /mnt` and check if the created folder exists.

wyzer
Contributor II

Hi,

Here is the result of of the "ls" command :

path                          name              size          modificationTime
dbfs:/mnt/${env]/      ${env]/		0		1654780637000
dbfs:/mnt/Temp/       Temp/		0		1643299456000
dbfs:/mnt/bronze/     bronze/		0		1655217261000
dbfs:/mnt/dev/          dev/		        0		1642150158000
dbfs:/mnt/extprd/      extprd/		0		0
dbfs:/mnt/gold/         gold/		0		1655197511000
dbfs:/mnt/prod/         prod/		0		1649774080000
dbfs:/mnt/qa/            qa/			0		1643122331000
dbfs:/mnt/silver/        silver/		0		1654676963000
dbfs:/mnt/uat/            uat/		0		1642150009000

I've used this command to create the folder :

CREATE OR REPLACE TABLE ${env}XXXXX.ZZZZ (
  .....
)
USING DELTA
OPTIONS (PATH '/mnt/${env]/gold/XXXXX/ZZZZ/')

As you can see, I've written "${env]" instead of "${env}'.

User16764241763
Honored Contributor

Hello @Salah K.​ 

Can you try below?

%sh rm -r /dbfs/mnt/$\{env\]

Thank you it works !!

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!