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 isfail.
-h, --help [help]Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are
options,examples,remarks,permissions,response,full. Default isoptions.--query [query]JMESPath query string. See http://jmespath.org/ for more information and examples.
-o, --output [output]Output type.
json,text,csv,md,none. Defaultjson.--verboseRuns command with verbose logging.
--debugRuns command with debug logging.
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.