cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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!

Welcome to Databricks Community: Lets learn, network and celebrate together

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.