file move
Moves a file to another location using the Microsoft Graph
Usage
m365 file move [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
,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
.--verbose
Runs command with verbose logging.
--debug
Runs command with debug logging.
Remarks
- If the source and target locations are within the same document library or drive, the command will utilize the Move DriveItem API, preserving the version history of the file.
- If the source and target locations are in different document libraries or drives, the command will use a copy-and-delete combination to move the file. Please note that in this case, version history will not be retained.
Examples
Move a file by server-relative URL to a folder in the same document library
m365 file move --webUrl "https://contoso.sharepoint.com/sites/project" --sourceUrl "/sites/project/Shared Documents/Document.pdf" --targetUrl "/sites/project/Shared Documents/NewFolder"
Move a file by server-relative URL to a document library in another site collection with server relative URL
m365 file move --webUrl "https://contoso.sharepoint.com/sites/project" --sourceUrl "/sites/project/Shared Documents/Document.pdf" --targetUrl "/sites/IT/Shared Documents"
Move a file by absolute URL to a document library in another site collection with absolute URL
m365 file move --webUrl "https://contoso.sharepoint.com" --sourceUrl "https://contoso.sharepoint.com/Shared Documents/Document.pdf" --targetUrl "https://contoso.sharepoint.com/sites/IT/Shared Documents"
Move a file to a document library in another site collection and rename the file
m365 file move --webUrl "https://contoso.sharepoint.com" --sourceUrl "/Shared Documents/Document.pdf" --targetUrl "/sites/IT/Shared Documents" --newName "newName"
Move 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 move --webUrl "https://contoso.sharepoint.com" --sourceUrl "/Shared Documents/Document.pdf" --targetUrl "/sites/IT/Shared Documents" --nameConflictBehavior rename
Move a file to Onedrive for business
m365 file move --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.