Skip to content

Latest commit

 

History

History
68 lines (44 loc) · 2.14 KB

file-copy.mdx

File metadata and controls

68 lines (44 loc) · 2.14 KB

import Global from '/docs/cmd/_global.mdx';

file copy

Copies a file to another location using the Microsoft Graph

Usage

m365 file copy [options]

Options

`-u, --webUrl <webUrl>`
: The URL of the site where the file is located.

`-s, --sourceUrl <sourceUrl>`
: Server-relative or absolute URL of the file.

`-t, --targetUrl <targetUrl>`
: Server-relative or absolute URL of the location.

`--newName [newName]`
: New name of the destination file.

`--nameConflictBehavior [nameConflictBehavior]`
: Behavior when a document with the same name is already present at the destination. Possible values: `fail`, `replace`, `rename`. Default is `fail`.

Examples

Copy a file by server-relative URL to a document library in another site collection with server relative URL

m365 file copy --webUrl https://contoso.sharepoint.com/sites/project --sourceUrl "/sites/project/Shared Documents/Document.pdf" --targetUrl "/sites/IT/Shared Documents"

Copy a file by absolute URL to a document library in another site collection with absolute URL

m365 file copy --webUrl https://contoso.sharepoint.com --sourceUrl "https://contoso.sharepoint.com/Shared Documents/Document.pdf" --targetUrl "https://contoso.sharepoint.com/sites/IT/Shared Documents"

Copy a file to a document library in another site collection and rename the file

m365 file copy --webUrl https://contoso.sharepoint.com --sourceUrl "/Shared Documents/Document.pdf" --targetUrl "/sites/IT/Shared Documents" --newName "newName"

Copy a file to a document library in another site collection and rename the file if a file with the same name already exists.

m365 file copy --webUrl https://contoso.sharepoint.com --sourceUrl "/Shared Documents/Document.pdf" --targetUrl "/sites/IT/Shared Documents" --nameConflictBehavior rename

Copy a file to Onedrive for business

m365 file copy --webUrl https://contoso.sharepoint.com --sourceUrl "/Shared Documents/Document.pdf" --targetUrl "https://contoso-my.sharepoint.com/personal/john_contoso_onmicrosoft_com/documents"

Response

The command won't return a response on success.