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 a file in DBFS with Illegal character?

aline_alvarez
New Contributor III

How can I delete a file in DBFS with Illegal character?

Someone put the file named "planejamento_[4098.]___SHORT_SAIA_JEANS__.xlsx" inside the folder /FileStore and I can delete it, because of this error: java.net.URISyntaxException: Illegal character in path at index 24.

I used: dbutils.fs.rm("/FileStore/planejamento_[4098.]___SHORT_SAIA_JEANS__.xlsx")

1 ACCEPTED SOLUTION

Accepted Solutions

-werners-
Esteemed Contributor III

try this

%sh

ls -li /dbfs

if the file is located in a subdirectory you can change the path mentioned above.

the %sh magic command gives you access to linux shell commands.

View solution in original post

6 REPLIES 6

-werners-
Esteemed Contributor III

you can try to use the %sh magic command and use rm.

Combined with this little help, it will probably work.

Thank you. I tried all the commands but none of them worked because the characters are "[" and "]". ๐Ÿ˜ฉ

-werners-
Esteemed Contributor III

it should still be possible.

can you try using ls -li (or ls -ia) first to get a list of files, then use the inode number (first column) and use it in the find- delete command:

> ls -li

> find . -inum <inodenumber> -delete

you can try without the -delete first to see if the file can be found

The file is in DBFS and doesn't show it with ls -li.

image.png

-werners-
Esteemed Contributor III

try this

%sh

ls -li /dbfs

if the file is located in a subdirectory you can change the path mentioned above.

the %sh magic command gives you access to linux shell commands.

Thank you!

It worked out!

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