Auditing Your Drive
Audit Scripts
For comprehensive auditing, scripts let you iterate over files, aggregate sharing data, and produce formatted reports. This goes beyond what the Sharing Panel and filters can show — you can generate tables, counts, and summaries across your entire Drive.
Example: Shared Files Audit
This script generates a report of all files you're sharing with others. Use the Sharing Panel to see exactly who you share with and drill down by person.
let shared_files = files(filter("is_shared:equals:true"), sort_order("name asc"));
log("Found " + shared_files.len().to_string() + " shared files");
let table = report_table_new();
report_table_title(table, "Shared Files Audit");
report_table_column(table, "File");
report_table_column_aligned(table, "Size (bytes)", "right");
report_table_column(table, "Type");
for f in shared_files {
report_table_add_row(table, [f.name, f.size.to_string(), f.mime_type]);
}
report_set_table(table);
Example: Public Files Report
Find all publicly shared files and generate a report:
let public_files = files(filter("shared_with:equals:public"), sort_order("name asc"));
log("Found " + public_files.len().to_string() + " public files");
let table = report_table_new();
report_table_title(table, "Public Files Audit");
report_table_column(table, "File");
report_table_column(table, "Owned by Me");
report_table_column(table, "Type");
for f in public_files {
report_table_add_row(table, [f.name, f.owned_by_me.to_string(), f.mime_type]);
}
report_set_table(table);
Example: Large Files by External Users
let external = files(filter("NOT owner_email:equals:me AND size:gt:10MB"), sort_order("size desc"));
let table = report_table_new();
report_table_title(table, "Large External Files");
report_table_column(table, "File");
report_table_column_aligned(table, "Size (bytes)", "right");
report_table_column(table, "Type");
for f in external {
report_table_add_row(table, [f.name, f.size.to_string(), f.mime_type]);
}
report_set_table(table);
Tips for Audit Scripts
- Use Dry Run to test scripts before running them — especially if the script includes mutations
- Limit results with the third parameter to
files()when testing (e.g.,files(filter(...), sort, 10)) - Combine with filters — the more specific your filter, the faster the script runs
- Save reports — scripts can save output to files on your Drive for future reference
Learn More
- Scripting Overview — Language guide and examples
- Script Reference — Complete function reference
- Reports — Building formatted reports
- Auditing Overview — All audit tools