🔍 Code Extractor

class MoveCopyOptions

Maturity: 38

A configuration class that encapsulates options for move and copy operations in SharePoint, controlling behavior like conflict resolution, metadata preservation, and lock bypassing.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/utilities/move_copy_options.py
Lines:
4 - 26
Complexity:
simple

Purpose

MoveCopyOptions is a data transfer object (DTO) that inherits from ClientValue and represents configuration settings for SharePoint file/folder move and copy operations. It allows fine-grained control over how metadata (author, editor, timestamps) is handled during these operations, whether to keep both files on conflicts, and whether to bypass shared locks. This class is typically used when calling SharePoint REST API methods that perform move or copy operations.

Source Code

class MoveCopyOptions(ClientValue):
    """"""

    def __init__(
        self,
        keep_both=True,
        reset_author_and_created_on_copy=False,
        retain_editor_and_modified_on_move=False,
        should_bypass_shared_locks=False,
    ):
        super(MoveCopyOptions, self).__init__()
        """
        :param bool retain_editor_and_modified_on_move: Specifies whether to retain the source of the move's editor
            and modified by datetime
        """
        self.KeepBoth = keep_both
        self.ResetAuthorAndCreatedOnCopy = reset_author_and_created_on_copy
        self.RetainEditorAndModifiedOnMove = retain_editor_and_modified_on_move
        self.ShouldBypassSharedLocks = should_bypass_shared_locks

    @property
    def entity_type_name(self):
        return "SP.MoveCopyOptions"

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

keep_both: Boolean flag (default: True) that determines whether to keep both the source and destination items when a naming conflict occurs during move/copy operations. When True, the system will rename one of the items to avoid overwriting.

reset_author_and_created_on_copy: Boolean flag (default: False) that specifies whether to reset the author and creation timestamp when copying items. When True, the copied item will have the current user as author and current time as creation date instead of preserving the original values.

retain_editor_and_modified_on_move: Boolean flag (default: False) that determines whether to preserve the original editor (last modified by) and modified datetime when moving items. When True, the moved item retains its original modification metadata; when False, it updates to current user and time.

should_bypass_shared_locks: Boolean flag (default: False) that controls whether the operation should bypass shared locks on items. When True, the operation can proceed even if items have shared locks that would normally prevent the operation.

Return Value

Instantiation returns a MoveCopyOptions object configured with the specified parameters. The object itself doesn't return values from methods but serves as a configuration container to be passed to SharePoint move/copy API methods. The entity_type_name property returns the string 'SP.MoveCopyOptions' which identifies this object type in SharePoint's REST API.

Class Interface

Methods

__init__(self, keep_both=True, reset_author_and_created_on_copy=False, retain_editor_and_modified_on_move=False, should_bypass_shared_locks=False)

Purpose: Initializes a new MoveCopyOptions instance with configuration flags for SharePoint move/copy operations

Parameters:

  • keep_both: Boolean to keep both items on naming conflicts (default: True)
  • reset_author_and_created_on_copy: Boolean to reset author and creation date on copy (default: False)
  • retain_editor_and_modified_on_move: Boolean to preserve editor and modified date on move (default: False)
  • should_bypass_shared_locks: Boolean to bypass shared locks during operation (default: False)

Returns: None (constructor)

@property entity_type_name(self) -> str property

Purpose: Returns the SharePoint entity type name for this options object, used for REST API serialization

Returns: String 'SP.MoveCopyOptions' representing the SharePoint entity type

Attributes

Name Type Description Scope
KeepBoth bool Stores whether to keep both items when a naming conflict occurs during move/copy operations instance
ResetAuthorAndCreatedOnCopy bool Stores whether to reset the author and creation timestamp when copying items instance
RetainEditorAndModifiedOnMove bool Stores whether to preserve the original editor and modified datetime when moving items instance
ShouldBypassSharedLocks bool Stores whether the operation should bypass shared locks on items instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

from office365.runtime.client_value import ClientValue
from office365.sharepoint.files.move_copy_options import MoveCopyOptions

# Create options for a copy operation that resets author and keeps both on conflict
options = MoveCopyOptions(
    keep_both=True,
    reset_author_and_created_on_copy=True,
    retain_editor_and_modified_on_move=False,
    should_bypass_shared_locks=False
)

# Create options for a move operation that preserves all metadata
move_options = MoveCopyOptions(
    keep_both=False,
    reset_author_and_created_on_copy=False,
    retain_editor_and_modified_on_move=True,
    should_bypass_shared_locks=True
)

# The options object would then be passed to SharePoint file/folder move or copy methods
# Example: file.moveto(new_url, move_options)
# Example: file.copyto(destination_url, options)

Best Practices

  • Instantiate this class with appropriate boolean flags before performing SharePoint move or copy operations
  • Use keep_both=True when you want to avoid accidental overwrites during copy operations
  • Set reset_author_and_created_on_copy=True when copying items and you want the copy to appear as newly created by the current user
  • Use retain_editor_and_modified_on_move=True when moving items and you need to preserve audit trail information
  • Only set should_bypass_shared_locks=True when you have appropriate permissions and understand the implications of bypassing locks
  • This is an immutable configuration object - create a new instance if you need different settings rather than modifying attributes after instantiation
  • The class inherits from ClientValue which handles serialization for SharePoint REST API communication
  • Default values are conservative (keep_both=True, others False) to prevent data loss

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class MoveCopyUtil 65.2% similar

    A utility class providing static methods for copying and moving files and folders in SharePoint, as well as downloading folders as zip archives.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/utilities/move_copy_util.py
  • class FilePickerOptions 63.9% similar

    A configuration class for SharePoint file picker options that extends ClientValue to specify search settings and organizational asset repositories.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/publishing/file_picker_options.py
  • class CallOptions 63.7% similar

    A data class that encapsulates optional configuration features for Microsoft Teams/Office 365 call functionality, specifically controlling bot visibility after escalation and content sharing notifications.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/communications/calls/options.py
  • class SharePointOneDriveOptions 62.9% similar

    A data class that encapsulates search content options for SharePoint and OneDrive searches performed using application permissions.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/search/sharepoint_onedrive_options.py
  • class AlterationOptions 60.8% similar

    A class representing search alteration options for spelling correction in Office 365 SharePoint search operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/search/alteration_options.py
← Back to Browse