> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encord.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Edit and Delete Files and Folders

## Update Folder Properties

Use the following script to update the name and description of an existing folder in **Data** > **Files & Folders**. Ensure that you:

* Replace `<private_key_path>` with the path to your private key.
* Replace `Cat Videos` with the name of the folder you want to update properties for.
* Replace `Cat videos and images` with the new name you want to give the folder.
* Replace `Images and videos of cats` with the description you want to give the folder.

<Tip>Use the [list\_storage\_folders]() and find\_storage\_folders methods to search for specific folders. </Tip>

<Tip>If you are updating many folders at once, pass a [Bundle](/sdk-documentation/sdk-references/http.bundle) to `folder.update` to batch the changes into a single server call. See [Bulk Action Best Practices](/sdk-documentation/general-sdk/sdk-bulk-action-best-practices) and keep bundle sizes under 1000 operations.</Tip>

<CodeGroup>
  ```python Single folder theme={"dark"}
  from encord import EncordUserClient
  from encord.orm.storage import FoldersSortBy

  # Instantiate Encord client using your SSH private key
  user_client = EncordUserClient.create_with_ssh_private_key(
      ssh_private_key_path="<private_key_path>"
  )

  # Define search parameters
  folder_name_to_find = "Cat Videos"
  search_result = user_client.find_storage_folders(
      search=folder_name_to_find,
      dataset_synced=None,
      order=FoldersSortBy.NAME,
      desc=False,
      page_size=1000
  )

  # Fetch the folder assuming it's the first one in the search result
  folder = next(search_result, None)
  if folder is None:
      print(f"No folder found with name {folder_name_to_find}")
  else:
      # Define new properties for the folder
      new_name = "Cat videos and images"
      new_description = "Images and videos of cats"

      # Update the folder properties
      folder.update(name=new_name, description=new_description)
      print(f"Folder '{folder_name_to_find}' updated to new name '{new_name}' and description '{new_description}'")
  ```

  ```python Bulk update (Bundle) theme={"dark"}
  from encord import EncordUserClient
  from encord.orm.storage import FoldersSortBy

  # Instantiate Encord client using your SSH private key
  user_client = EncordUserClient.create_with_ssh_private_key(
      ssh_private_key_path="<private_key_path>"
  )

  # Map current folder names to the new properties you want to apply.
  folder_updates = {
      "Cat Videos": {
          "name": "Cat videos and images",
          "description": "Images and videos of cats",
      },
      "Dog Videos": {
          "name": "Dog videos and images",
          "description": "Images and videos of dogs",
      },
  }

  # Collect folders first so the search calls are not bundled.
  folders_to_update = []

  for folder_name, new_props in folder_updates.items():
      folder = next(
          user_client.find_storage_folders(
              search=folder_name,
              dataset_synced=None,
              order=FoldersSortBy.NAME,
              desc=False,
              page_size=1000,
          ),
          None,
      )

      if folder is None:
          print(f"No folder found with name '{folder_name}'")
          continue

      folders_to_update.append((folder, folder_name, new_props))

  # Apply all updates using bundled requests.
  with user_client.create_bundle(bundle_size=1000) as bundle:
      for folder, old_folder_name, new_props in folders_to_update:
          folder.update(
              name=new_props["name"],
              description=new_props["description"],
              bundle=bundle,
          )

          print(
              f"Queued update for '{old_folder_name}' -> "
              f"'{new_props['name']}' with description "
              f"'{new_props['description']}'"
          )

  print("Bundled folder updates executed.")
  ```
</CodeGroup>

***

## Move Folders

You can move folders between different parent folders in **Data** > **Files & Folders**, including moving them to the root (no parent). The following script demonstrates how a folder with the name `Folder Name 3` is moved between 2 different target folders. The script must be modified to suit your needs.

Ensure that you:

* Replace `<private_key_path>` with the path to your private key.
* Replace `Folder Name 1` with the name of a target folder.
* Replace `Folder Name 2` with the new name of another target folder.
* Replace `Folder Name 3` with the name of the folder that is moved.

```python Folders theme={"dark"}
from encord import EncordUserClient
from encord.storage import FoldersSortBy

# Instantiate Encord client by substituting the path to your private key
user_client = EncordUserClient.create_with_ssh_private_key(
                ssh_private_key_path="<private_key_path>"
            )

# Search for folders by name using the find_storage_folders function
folder_1 = next(user_client.find_storage_folders(search="Folder Name 1", dataset_synced=False, order=FoldersSortBy.NAME, desc=False, page_size=1000))
folder_2 = next(user_client.find_storage_folders(search="Folder Name 2", dataset_synced=False, order=FoldersSortBy.NAME, desc=False, page_size=1000))
folder_3 = next(user_client.find_storage_folders(search="Folder Name 3", dataset_synced=False, order=FoldersSortBy.NAME, desc=False, page_size=1000))

# Move folder_3 under folder_1
folder_3.move_to_folder(folder_1.uuid)

# Move folder_3 under folder_2
folder_3.move_to_folder(folder_2.uuid)

# Move folder_3 to root folder (passing None moves it to the root level)
folder_3.move_to_folder(None)
```

***

## Delete Folders

Use the following script to delete a specific folder from **Data** > **Files & Folders**. Ensure that you:

* Replace `<private_key_path>` with the path to your private key.
* Replace `Specific Folder Name` with the name of the folder you want to delete.

```python theme={"dark"}
from encord import EncordUserClient
from encord.storage import FoldersSortBy

# Instantiate Encord client by substituting the path to your private key
user_client = EncordUserClient.create_with_ssh_private_key(
                ssh_private_key_path="<private_key_path>"
            )

# Define the search criteria for the folder
folder_search_criteria = "Specific Folder Name"

# Retrieve the target folder
try:
    folder_to_delete = next(user_client.find_storage_folders(search=folder_search_criteria, dataset_synced=None, order=FoldersSortBy.NAME, desc=False, page_size=1000))
    print(f"Deleting folder {folder_to_delete.uuid}")

    # Delete the folder and verify it cannot be accessed anymore
    folder_to_delete.delete()
    print("Folder deleted successfully.")

    try:
        # Try to refetch the folder to verify it's been deleted
        user_client.get_storage_folder(folder_to_delete.uuid)
        print("Error: Folder still accessible after deletion.")
    except Exception as e:
        print(f"Verification successful: {str(e)}")

except StopIteration:
    print("No folder found with the specified criteria.")
```
