Skip to main content

spo folder move

Moves a folder to another location

Usage

m365 spo folder move [options]

Options

-u, --webUrl <webUrl>

The URL of the site where the folder is located.

-s, --sourceUrl [sourceUrl]

The server-, site-relative or absolute decoded URL of the folder to move. Specify either sourceUrl or sourceId but not both.

-i, --sourceId [sourceId]

The ID of the folder to move. Specify either sourceUrl or sourceId but not both.

-t, --targetUrl <targetUrl>

Server-relative or absolute decoded URL where to move the folder.

--newName [newName]

The new name of the destination folder.

--nameConflictBehavior [nameConflictBehavior]

Behavior when a file or folder with the same name is already present at the destination. Allowed values: fail, rename. Defaults to fail.

--retainEditorAndModified

Use this option to retain the editor and modified date. When not specified, these values are reset.

--bypassSharedLock

This indicates whether a folder with a share lock can still be moved. Use this option to move a folder that is locked.

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Remarks

All folder versions are retained while moving a folder.

When you specify a value for nameConflictBehavior, consider the following:

  • fail will throw an error when the destination folder already exists.
  • rename will add a suffix (e.g. folder1) when the destination folder already exists.

Examples

Move a folder to a document library in another site collection by server-relative URL.

m365 spo folder move --webUrl https://contoso.sharepoint.com/sites/project-x --sourceUrl "/sites/project-x/Shared Documents/Reports" --targetUrl "/sites/project-y/Shared Documents/Reports January"

Move a folder to another location using site-relative URLs and rename it.

m365 spo folder move --webUrl https://contoso.sharepoint.com/sites/project-x --sourceUrl "/Shared Documents/Reports" --targetUrl "/sites/project-y/Shared Documents" --newName "Reports January"

Move a folder to another location and use a new name on conflict.

m365 spo folder move --webUrl https://contoso.sharepoint.com/sites/project-x --sourceUrl "/sites/project-x/Shared Documents/Reports" --targetUrl "/sites/project-y/Shared Documents/Project files" --nameConflictBehavior rename

Move a folder referenced by its ID to another document library and retain editor and modified date.

m365 spo folder move --webUrl https://contoso.sharepoint.com/sites/project-x --sourceId b8cc341b-9c11-4f2d-aa2b-0ce9c18bcba2 --targetUrl "/sites/project-x/Project files" --retainEditorAndModified

Response

The command won't return a response on success.

More information

CTRL + M