Skip to main content

file list

Retrieves files from the specified folder and site

Usage

m365 file list [options]

Options

-u, --webUrl <webUrl>

The URL of the site where the folder from which to retrieve files is located

--folderUrl <folderUrl>

The server- or site-relative URL of the folder from which to retrieve files

--recursive

Set to retrieve files from subfolders

-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

This command is an improved version of the spo file list command. The main difference between the two commands is, that file list uses Microsoft Graph and properly supports retrieving files from large folders. Because file list uses Microsoft Graph and spo file list uses SharePoint REST APIs, the data returned by both commands is different.

Examples

Return all files from the folder Shared Documents located in site https://contoso.sharepoint.com/sites/project-x

m365 file list --webUrl https://contoso.sharepoint.com/sites/project-x --folderUrl 'Shared Documents'

Return all files from the folder Shared Documents and all the sub-folders of Shared Documents located in site https://contoso.sharepoint.com/sites/project-x

m365 file list --webUrl https://contoso.sharepoint.com/sites/project-x --folderUrl 'Shared Documents' --recursive

Return all files from the Important folder in the Shared Documents document library located in site https://contoso.sharepoint.com/sites/project-x

m365 file list --webUrl https://contoso.sharepoint.com/sites/project-x --folderUrl 'Shared Documents/Important'
[
{
"@microsoft.graph.downloadUrl": "https://contoso.sharepoint.com/_layouts/15/download.aspx?UniqueId=9bdc8c49-644a-4875-aaa3-82914fb23226&Translate=false&tempauth=&ApiVersion=2.0",
"createdDateTime": "2024-02-14T22:41:41Z",
"eTag": "\"{9BDC8C49-644A-4875-AAA3-82914FB23226},1\"",
"id": "013TMHP6SJRTOJWSTEOVEKVI4CSFH3EMRG",
"lastModifiedDateTime": "2024-02-14T22:41:41Z",
"name": "Document.docx",
"webUrl": "https://contoso.sharepoint.com/_layouts/15/Doc.aspx?sourcedoc=%7B9BDC8C49-644A-4875-AAA3-82914FB23226%7D&file=Document.Docx&action=default&mobileredirect=true",
"cTag": "\"c:{9BDC8C49-644A-4875-AAA3-82914FB23226},2\"",
"size": 41554,
"createdBy": {
"user": {
"email": "john@contoso.com",
"id": "fe36f75e-c103-410b-a18a-2bf6df06ac3a",
"displayName": "John Doe"
}
},
"lastModifiedBy": {
"user": {
"email": "john@contoso.com",
"id": "fe36f75e-c103-410b-a18a-2bf6df06ac3a",
"displayName": "John Doe"
}
},
"parentReference": {
"driveType": "documentLibrary",
"driveId": "b!T4-bE44OMEa7ClAUQtubZID9tc40pGJKpguycvELod_YogR_WYHeSaTWzIZ6qMyU",
"id": "013TMHP6V6Y2GOVW7725BZO354PWSELRRZ",
"name": "TEST",
"path": "/drives/b!T4-bE44OMEa7ClAUQtubZID9tc40pGJKpguycvELod_YogR_WYHeSaTWzIZ6qMyU/root:",
"siteId": "0f9b8f4f-0e8e-4630-bb0a-501442db9b64"
},
"file": {
"mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"hashes": {
"quickXorHash": "MX9jeQT/AfhDDMpYygXlCPYI/kc="
}
},
"fileSystemInfo": {
"createdDateTime": "2024-02-14T22:41:41Z",
"lastModifiedDateTime": "2024-02-14T22:41:41Z"
},
"shared": {
"scope": "users"
},
"lastModifiedByUser": "John Doe"
}
]
CTRL + M