Skip to content

spo folder copy

Copies a folder to another location

Usage

spo folder copy [options]

Options

Option Description
--help output usage information
-u, --webUrl <webUrl> The URL of the site where the folder is located
-s, --sourceUrl <sourceUrl> Site-relative URL of the folder to copy
-t, --targetUrl <targetUrl> Server-relative URL where to copy the folder
--allowSchemaMismatch Ignores any missing fields in the target document library and copies the folder anyway
-o, --output [output] Output type. json|text. Default text
--verbose Runs command with verbose logging
--debug Runs command with debug logging

Important

Before using this command, log in to a SharePoint Online site, using the spo login command.

Remarks

To copy a folder, you have to first log in to a SharePoint Online site using the spo login command, eg. spo login https://contoso.sharepoint.com.

When you copy a folder with documents that have version history, only the latest document version is copied.

Examples

Copies folder from a document library located in one site collection to another site collection

spo folder copy --webUrl https://contoso.sharepoint.com/sites/test1 --sourceUrl /Shared%20Documents/MyFolder --targetUrl /sites/test2/Shared%20Documents/

Copies folder from a document library to another site in the same site collection

spo folder copy --webUrl https://contoso.sharepoint.com/sites/test1 --sourceUrl /Shared%20Documents/MyFolder --targetUrl /sites/test1/HRDocuments/

Copies folder to a document library in another site collection. Allow for schema mismatch

spo folder cope --webUrl https://contoso.sharepoint.com/sites/test1 --sourceUrl /Shared%20Documents/MyFolder --targetUrl /sites/test2/Shared%20Documents/ --allowSchemaMismatch

More information