How to Export File Metadata from Google Drive
Google Drive has no built-in 'export file list' button. Here are three proven methods to get your file metadata into a spreadsheet.
Google Drive does not have a button to export your file metadata as a spreadsheet. You cannot select a folder and download a CSV of all files with their names, sizes, owners, and dates. The three methods below are the standard approaches, ranging from no-code to developer-level.
Google Apps Script to Google Sheet
This is the simplest approach. You paste a short script into Google Apps Script, run it, and your file metadata appears directly in a Google Sheet. No installations, no API keys, no command line. Once in a Sheet, you can download it as CSV, XLSX, or keep it in Sheets.
DriveApp.getFiles() with DriveApp.getFolderById('YOUR_FOLDER_ID').getFiles().function listDriveFiles() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.clear();
sheet.appendRow([
"File Name", "File ID", "URL", "Size (bytes)", "Type",
"Created", "Last Updated", "Owner", "Description", "Sharing"
]);
var files = DriveApp.getFiles();
// To scan a specific folder instead:
// var files = DriveApp.getFolderById("YOUR_FOLDER_ID").getFiles();
while (files.hasNext()) {
var file = files.next();
sheet.appendRow([
file.getName(),
file.getId(),
file.getUrl(),
file.getSize(),
file.getMimeType(),
file.getDateCreated(),
file.getLastUpdated(),
file.getOwner() ? file.getOwner().getEmail() : "",
file.getDescription() || "",
file.getSharingAccess() + " / " + file.getSharingPermission()
]);
}
}PropertiesService and use a time-based trigger to resume. Or consider Method 2 for large-scale exports.Python + Google Drive API v3
The Drive API gives you the most control over which metadata fields to extract and how to format the output. This method handles pagination natively and can export tens of thousands of files without the time limits of Apps Script.
pip install google-api-python-client google-auth-oauthlibfields parameter to include or exclude specific metadata.from googleapiclient.discovery import build
from google.oauth2 import service_account
import csv
# Authenticate (adjust path to your credentials file)
creds = service_account.Credentials.from_service_account_file(
"credentials.json",
scopes=["https://www.googleapis.com/auth/drive.readonly"]
)
service = build("drive", "v3", credentials=creds)
# Paginate through all files
all_files = []
page_token = None
while True:
results = service.files().list(
pageSize=1000,
fields="nextPageToken, files(id, name, mimeType, createdTime, "
"modifiedTime, owners, size, description, shared, "
"parents, webViewLink)",
pageToken=page_token,
supportsAllDrives=True,
includeItemsFromAllDrives=True
).execute()
all_files.extend(results.get("files", []))
page_token = results.get("nextPageToken")
if not page_token:
break
# Write to CSV
with open("google_drive_metadata.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow([
"ID", "Name", "MIME Type", "Created", "Modified",
"Owner", "Size", "Description", "Shared", "Link"
])
for file in all_files:
writer.writerow([
file.get("id"),
file.get("name"),
file.get("mimeType"),
file.get("createdTime"),
file.get("modifiedTime"),
file["owners"][0]["emailAddress"] if file.get("owners") else "",
file.get("size", "N/A"),
file.get("description", ""),
file.get("shared"),
file.get("webViewLink", "")
])
print(f"Exported {len(all_files)} files to google_drive_metadata.csv")permissions (who has access), starred, md5Checksum, version, and labelInfo (Enterprise labels). See the Drive API Files resource documentation for the full list.Rclone CLI
Rclone is a free, open-source command-line tool that supports 40+ cloud storage providers. It can list all files in your Google Drive as structured JSON, which you then convert to CSV. No coding required beyond a one-line command.
rclone config and follow the prompts to authorize Rclone to access your Drive. This creates a named remote (e.g., "gdrive").# List all files as JSON
rclone lsjson gdrive: --recursive > drive_files.json
# Convert JSON to CSV (requires Python or jq)
python3 -c "
import json, csv, sys
with open('drive_files.json') as f:
data = json.load(f)
w = csv.DictWriter(sys.stdout,
fieldnames=['Path','Name','Size','MimeType','ModTime','IsDir'])
w.writeheader()
for item in data:
w.writerow(item)
" > google_drive_metadata.csvWhat metadata fields can you export?
| Field | Apps Script | Drive API | Rclone |
|---|---|---|---|
| File name | ✓ | ✓ | ✓ |
| File path / parent folder | ✕ | ✓ | ✓ |
| File size | ✓ | ✓ | ✓ |
| MIME type | ✓ | ✓ | ✓ |
| Created date | ✓ | ✓ | ✕ |
| Modified date | ✓ | ✓ | ✓ |
| Owner email | ✓ | ✓ | ✕ |
| Description | ✓ | ✓ | ✕ |
| Sharing permissions | Basic | Detailed | ✕ |
| Web view URL | ✓ | ✓ | ✕ |
| Starred | ✕ | ✓ | ✕ |
| MD5 / SHA checksum | ✕ | ✓ | MD5 only |
| Labels (Enterprise) | ✕ | ✓ | ✕ |
| Version number | ✕ | ✓ | ✕ |
- Google-native files (Docs, Sheets, Slides) do not have a file size in Drive. The
sizefield returns empty for these file types. - Drive Labels (custom structured metadata) require Google Workspace Enterprise and the Drive Labels API. They are not available on personal or Business Starter accounts.
- Shared Drives require the
supportsAllDrivesandincludeItemsFromAllDrivesflags in API calls. Apps Script'sDriveAppclass does not support Shared Drives natively — use the Advanced Drive Service instead.
You have your metadata export.
Now score it.
Upload your CSV or Excel file to MQS and get a structural metadata health score out of 100 with dimension breakdowns and actionable diagnostics.