spo file rename
Renames a file
Usage
m365 spo file rename [options]
Options
-u, --webUrl <webUrl>The URL of the site where the file is located
-s, --sourceUrl <sourceUrl>The server- or site-relative URL of the file to rename
-t, --targetFileName <targetFileName>New file name of the file
--forceIf a file already exists with target file name, it will be moved to the recycle bin. If omitted, the rename operation will be canceled if a file already exists with the specified file name
-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 isfull.--query [query]JMESPath query string. See http://jmespath.org/ for more information and examples.
-o, --output [output]Output type.
json,text,csv,md. Defaultjson.--verboseRuns command with verbose logging.
--debugRuns command with debug logging.
Remarks
If you try to rename a file without the --force flag and a file with this name already exists, the operation will be cancelled.
Examples
Renames a file with server-relative URL /Shared Documents/Test1.docx located in site https://contoso.sharepoint.com/sites/project-x to Test2.docx
m365 spo file rename --webUrl https://contoso.sharepoint.com/sites/project-x --sourceUrl '/Shared Documents/Test1.docx' --targetFileName 'Test2.docx'
Renames a file with server-relative URL /Shared Documents/Test1.docx located in site https://contoso.sharepoint.com/sites/project-x to Test2.docx. If the file with the target file name already exists, this file will be moved to the recycle bin
m365 spo file rename --webUrl https://contoso.sharepoint.com/sites/project-x --sourceUrl '/Shared Documents/Test1.docx' --targetFileName 'Test2.docx' --force