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
Databricks Employee
Databricks Employee

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 !!

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