Index
Moving Files and Folders
Moving files
Use the following script to move various types of files to a different folder in Files. Ensure that you:
- Replace <private_key_path> with the path to your private key.
- Replace
File Name
with the name of the file you want to move to a new folder. - Replace
Target Folder Name
with the name of the folder you want to move the file to.
Moving folders
You can move folders between different parent folders in Files, 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.
Folders
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)
Was this page helpful?