API Reference

Use the move method to move files and directories to a new parent directory.

try {
  const id = 'target_directory_id'; // The ID of the new parent directory.
  const directoryIdsToMove = ['directory_id_1', 'directory_id_2']; // An array of directory IDs to move.
  const fileIdsToMove = ['file_id_1', 'file_id_2']; // (optional) An array of file IDs to move.

  const [data, error] = await sdk.directory.move({
    id,
    directoryIdsToMove,
    fileIdsToMove
  });

  // Check for success
  if (error) {
    console.error('Failed to move files and directories:', error);
  } else {
    console.log('Files and directories moved successfully.');
  }
} catch (error) {
  console.error('An unexpected error occurred:', error.message);
}

Params

  • id (string): The ID of the new parent directory where the child directories/files will be moved.
  • directoryIdsToMove (string[]): An array of directory IDs to move. (must be in the same drive)
  • fileIdsToMove (string[], optional): An array of file IDs to move. (must be in the same drive)

Required API Key Permission

  • Create Directory
  • Delete Directory