Deleting nwb files from dandisets #139
-
I apologize if this is a basic question, but I wanted to ask if there is a way to delete all the uploaded NWB files at once from a dandiset that has not been published yet. I can find the option to delete them one by one, but I have around 200 files, and it would be very helpful if I could delete them all at once. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Not through the website, but you can do these via the Python API Set an environment variable called import os
from pathlib import Path
from dandi.dandiapi import DandiAPIClient
# Form a list of filenames you wish to delete; e.g., `sub-ABC_ses-123.nwb`
dandi_file_paths_to_remove = [...]
client = DandiAPIClient(token=os.environ["DANDI_API_KEY"])
dandiset = client.get_dandiset(dandiset_id="<enter your six-digit dandiset ID>")
assets = list(dandiset.get_assets()) # This fetches all live assets on the dandiset
assets_to_remove = [asset for asset in assets if Path(assets.path).name in dandi_file_paths_to_remove]
# The batch delete command
for asset_to_remove in assets_to_remove:
asset_to_remove.delete() |
Beta Was this translation helpful? Give feedback.
-
See/use https://dandi.readthedocs.io/en/latest/cmdline/delete.html |
Beta Was this translation helpful? Give feedback.
Not through the website, but you can do these via the Python API
Set an environment variable called
DANDI_API_KEY
equal to your usual DANDI token