SharePoint Online - Copy or move a file

Use the SharePoint Online - Copy or move a file action A tool for building the processes, logic, and direction within workflows. to copy or move a file from one document library to another when you specify the source file and destination location. You can also copy or move files into a different site collection in the same SharePoint tenant.

Note: 
  • The selection made for the Delete source file when complete option in the action configuration determines if the file is copied or moved to the destination. Select, Yes to move the file and No, to copy the file. For more information, see Delete source file when complete.
  • Renaming the copied or moved file is only supported when you choose to attach the file to an existing item in a list by selecting the Attach file to item option in the Specify destination by configuration field. For a detailed description of the configuration fields, see SharePoint Online - Copy or move a file action fields and settings.

Configure the SharePoint Online - Copy or move a file action

Important: Before inserting variables in the action configuration, you must manually type or select the values and populate other dependent fields in order to retrieve the output data. Once configured, you can insert variables to the required fields.

  1. Open the action configuration panel. For more information, see Add an action.

  2. Select a Connection. If you do not have a connection, see Add a connection on the Connections page.

    Note: 

    Only the connections created with the List and libraries authentication method will be available in the Connection drop-down.

    For more information about authentication methods for SharePoint Online connections, see Authentication methods for SharePoint Online connections.

  1. Select an option in Specify source by to define how you want to select the source file. The configuration fields that display in the Source file section depend on the option selected.
  2. Depending on the option selected in Step 3 do one of the following to specify the source file:
  1. In the Destination location section, select the Specify destination by option to define how you want to select the destination to copy or move the file to. The configuration fields that display in the Destination location section depend on the option selected.
  2. Depending on the option selected in Step 5, do one of the following to specify the destination to copy or move the file to:
  3. Note: Renaming the copied or moved file is only supported when you choose to attach the file to an existing item in a list by selecting the Attach file to item option.

SharePoint Online - Copy or move a file action fields and settings

Important: Before inserting variables in the action configuration, you must manually type or select the values and populate other dependent fields in order to retrieve the output data. Once configured, you can insert variables to the required fields.

Section Field Description Variable types
(unlabeled)

Connection Credentials and other settings required to pass data between the workflow and the indicated service, which could be a cloud service, business application, or content store.

SharePoint Online connection to use to access the SharePoint Online site.

To refresh the available connections, click Refresh.

(n/a)
Source file Specify source by

Select one of the following options to define how you want to specify the source file:

Note: The configuration fields that are displayed in the Source file section depend on the option selected for Specify source by.

  • Choose file: Specify the source file using the document library and the path to the file.
  • Item ID: Specify the source using the Item ID.
  • URL:  Specify source file using the direct URL to the file.
(n/a)
  SharePoint site URL

(Available only if Choose file or Item ID is selected in the Specify source by field).

The URL of the SharePoint Online site that has the list or document library you want to use.

To retrieve the lists for the SharePoint site URL, type the SharePoint site URL and click Retrieve lists.

Example: https://domain.sharepoint.com/sites/hr

Boolean, Collection, DateTime, Decimal, Integer, Text
 

Document library

(Available only if Choose file or Item ID is selected in the Specify source by field).

The name of the document library containing the file you want to copy or move.

When you specify the SharePoint Online site URL, all the document libraries in the selected site will be available to select from in the Document library drop-down list.

Boolean, Collection, DateTime, Decimal, Integer, Text

 

File path

(Available only if Choose file is selected in the Specify source by field).

The path, including file name, for the file you want to copy.

Note: 
  • If the File path is incorrect or does not exist the workflow will fail.
  • If the file is located in a folder, you must specify the folder path. Example: /reports/report.docx
  • If the file is located in the root directory, you can type only the filename. Example: report.docx.

Boolean, Collection, DateTime, Decimal, Integer, Text

  Item ID

(Available only if Item ID is selected in the Specify source by field).

The ID of the list item you want to copy to another list.

Integer
  File URL

(Available only if URLis selected in the Specify source by field).

The URL of the of the file you want to copy or move.

Example :https://domain.sharepoint.com/sites/hr/report.pdf

Boolean, Collection, DateTime, Decimal, Integer, Text
  Delete source file when complete

Select Yes or No to specify whether you want to delete the source file after completing the action. The option you select in this field determines if the file is copied or moved to the destination as described below:

  • Yes: Moves the file to the new destination and deletes the file from the source document library.
  • No: Copies the file from the source to the destination document library and the source file remains in the source destination.
Boolean
Destination location Specify destination by

Select one of the following options to define how you want to specify the destination location:

Note: The configuration fields that are displayed in the Destination location section depend on the option you select for Specify destination by.

  • Choose location: Specify the destination location using the document library and the path to the file. With this option renaming the file is not possible and the source file will be copied or moved to the destination with the same name.
  • URL:  The URL to the destination document library you want to copy or move the file to. With this option renaming the file is not possible and the source file will be copied or moved to the destination with the same name.
  • Attach file to item: Specify an item in a list you want to attach the file to. With this option you can rename the copied or moved file to have a different name in the destination.
  • Important: When attaching the file to an item, the size of the file cannot exceed 250MB. If the file size of the file you have selected to copy or move is greater than 250MB and the Specify destination by option selected is Attach file to item, the action will fail.

(n/a)
  SharePoint site URL

(Available only if Choose locationor Attach file to item is selected in the Specify destination by field).

The URL of the destination SharePoint Online site you want to copy or move the file to.

To retrieve the lists for the SharePoint site URL, type the SharePoint site URL and click Retrieve lists.

Example: https://domain.sharepoint.com/sites/hr

Boolean, Collection, DateTime, Decimal, Integer, Text
 

Document library

(Available only if Choose location is selected in the Specify destination by field).

The name of the document library you want to copy or move the file to.

When you specify the SharePoint Online site URL, all the document libraries in the selected site will be available to select from in the Document library drop-down list.

Boolean, Collection, DateTime, Decimal, Integer, Text

 

Folder path

(Available only if Choose location is selected in the Specify destination by field).

The path for the new location of the copied or moved file.

Example: /documents/drafts

Note: 
  • If a folder path is not specified, the file is saved to the root level of the document library.
  • If the folder does not exist in the specified path, a new folder is created.

Boolean, Collection, DateTime, Decimal, Integer, Text

  Document library URL

(Available only if URL is selected in the Specify destination by field).

The URL to the destination document library you want to copy or move the file to.

Example: https://domain.sharepoint.com/sites/hr/shared documents

Boolean, Collection, DateTime, Decimal, Integer, Text
  List name

(Available only if Attach file to item is selected in the Specify destination by field).

The name of the list that has the item you want to attach the file to.

Boolean, Collection, DateTime, Decimal, Integer, Text
  Item ID

(Available only if Attach file to item is selected in the Specify destination by field).

The ID of the item you want to attach the file to.

Integer
  New file name

(Available only if Attach file to item is selected in the Specify destination by field).

The name for the file that is attached to an existing item.

Boolean, Collection, DateTime, Decimal, Integer, Text
 

Overwrite file with the same name

Select Yes or No to specify whether you want to overwrite any existing file that has the same name in the destination.

  • Yes: If a file with the same file name exists in the destination, it will be replaced with the new document.
  • No: If No is selected and a file with the same file name exists in the destination, the workflow will fail.

Boolean

Output

Result

Stores the result of the action in an object with the following variables:

  • Attachment URL: Text variable to store the URL of the attachment attached to the copied or moved file.
  • File name: Text variable to store the name of the copied or moved file.
  • File path: Text variable to store the new path of the copied or moved file.
  • File URL: Text variable to store the URL of the file in the new destination.
  • Folder path: Text variable to store the new folder path.
  • Item ID: Integer variable to store the ID of the file in the destination.
  • List name: Text variable to store the name of the list the file is copied or moved to.
  • Site URL: Text variable to store the URL of the site the file is stored in.

Object