- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 05:28 AM
Is there a way to delete recursively files using a command in notebooks
since in the below directory i have many combination of files like .txt,,png,.jpg but i only want to delete files with .csv
example dbfs:/FileStore/.csv*
- Labels:
-
Command
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 12:31 AM
Hi @Rakesh Reddy Gopidi
You can use the os module to iterate over a directory.
By using a loop over the directory, you can check what the file ends with using .endsWith(".csv).
After fetching all the files, you can remove it.
Hope this helps..
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 05:30 AM
%fs rm -r dbfs:/FileStore/.csv*
dbutils.fs.rm('dbfs:/FileStore/.csv*', True)
is this correct ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 12:31 AM
Hi @Rakesh Reddy Gopidi
You can use the os module to iterate over a directory.
By using a loop over the directory, you can check what the file ends with using .endsWith(".csv).
After fetching all the files, you can remove it.
Hope this helps..
Cheers.

