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!

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!