Is there any way to see all publicly shared Google Drive items/documents from a specific Google user?


I wrote a Google Apps Script macro that you can attach to a new spreadsheet (or an old one, if it would make any sense) that accomplishes this task. To attach a script to a spreadsheet, go into that spreadsheet (or create a new one), click "Tools"->"Script editor...", copy and paste the code into the editor, click "Resources"->"Current project's triggers," select "onOpen" under Run, select "From spreadsheet" under Events, make sure the third drop-down menu reads "On open," then save the script under a name of your choice.

The code below:

  1. asks you to enter the email address of the user for whom you want to get a list of shared files
  2. creates a new sheet within the active spreadsheet
  3. populates it with two columns of data: one with the names of all of the publicly shared files owned by the user you specified AND live hyperlinks to those files, and a second column containing the names of the folders containing these files

Here's the code:

function doGet() {

  var owner = SpreadsheetApp.getUi().prompt("Enter owner's email address:").getResponseText();
  var ssheet = SpreadsheetApp.getActive();
  var newSheet = ssheet.insertSheet(owner);

  newSheet.getRange('A1:B1').setValues([["File Name","Containing Folder"]]);
  var cells = newSheet.getRange('A1:B500');

  var files = DriveApp.getFiles();
  var ownerFiles = [];
  while (files.hasNext()){
    var file = files.next();
    if (file.getOwner().getEmail()==owner && file.getSharingAccess()==DriveApp.Access.ANYONE) {

  for (i=0; i<ownerFiles.length; i++){
    cells.getCell(i+2,1).setValue("=HYPERLINK(" + ownerFiles[i].getUrl() + "," + ownerFiles[i].getName() + ")");

    var folders = ownerFiles[i].getParents();
    var folder = folders.next();

function onOpen() {
                        .addItem('Public Files Owned by...', 'doGet')

To run the script, reopen the spreadsheet after first saving the script, then click "List"->"Public Files Owned by...".

Something to bear in mind is that this is an inefficient script; if you have a lot of files stored in your Drive, this could take a long time to execute. In addition, it is currently written to accommodate up to 499 entries. (Increasing this maximum is simply a matter of raising the number for the 'B' column in the cells declaration.) It is also currently written to output only the first parent folder if a file is contained in multiple folders.

  • I fully realise that this is an inefficient script; if anybody has any ideas for improving its efficiency, please do edit my post. I was also unable to debug the majority of the script due to time constraints, so I am not 100% sure this will work. Nov 10 '16 at 21:05

If you are admin you can use the Drige API with a service account impersonating that user.

  • Asker made no mention that this was a Google Apps account.
    – ale
    Sep 5 '15 at 20:25
  • You are right. Then, only those shared directly with you or those you have opened.
    – Riël
    Sep 5 '15 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.