Google-drive – search the google drive for all documents that have been shared with a link privately or are open on the web

google-drivegoogle-drive-search

Is it possible to search for all google drive documents that have been shared with a link privately or are open on the web ?

In the advance search you can search for files shares with particular people, but i would like to run a report on files shared either with a link privately or are open on the web.

Best Answer

It seems Drive URL query parameters doesn't support such searching now(It was probably removed in 2009). The only way you can search by those parameters now is probably by google-apps-script or DRIVE REST API.


  • Official search parameters support only to:email parameter. So,If you know the email address,You can easily filter out the files.

  • GOOGLE-APPS-SCRIPT

    function driveSearch() {
      // Log the name of every file in the user's Drive whose visibility is anyonewithLink or anyonecanfind
      var files = DriveApp.searchFiles(
        'visibility = "anyoneWithLink" or visibility = "anyoneCanFind"');
      while (files.hasNext()) {
        var file = files.next();
        //var owner = file.getOwner().getName();
        //var sa = file.getSharingAccess();
        Logger.log(file.getName());
        //Logger.log('Owner:'+owner);
        //Logger.log("SharingAccess:"+sa);
      }
      }
    

Sample Python Code from the official documentation

    page_token = None
    while True:
    response = drive_service.files().list(q="mimeType='image/jpeg'",
                                      spaces='drive',
                                      fields='nextPageToken, files(id, name)',
                                      pageToken=page_token).execute()
    for file in response.get('files', []):
    # Process change
    print 'Found file: %s (%s)' % (file.get('name'), file.get('id'))
    page_token = response.get('nextPageToken', None)
    if page_token is None:
    break