3

If I delete a document owned by me, everybody loses access to that document. However, if I delete a document owned by someone else, it is only deleted from my point of view. Everybody else still sees that document.

In an environment where everybody is responsible for maintaining a pool of documents, this is terribly confusing. How do I delete a document on behalf of another user so that the document is gone for everybody?

Edit For Google Apps accounts, this was resolved nicely in late 2018 with the introduction of the Team Drive feature. We've had good experience with the co-ownership use case I described above after moving documents into one.

Jury is still out on a good solution for personal accounts.

3

To work around the problem, you can use a naming convention and a script. E.g., the users can agree to consider a file deleted if its name is "zzz_delete_this_file" (multiple files can have the same name in Google Drive).

Users can also install the following script (general information on scripts) and have it run every hour or every minute:

function myFunction() {
  var files = DriveApp.getFilesByName("zzz_delete_this_file");
  while (files.hasNext()) {
   var file = files.next();
   file.setTrashed(true);
  }
}

This moves all files with such a name into trash; in 30 days they get deleted.

2

With consumer accounts it's not possible to delete files owned by someone else.

Bear in mind that users can transfer the file ownership of files created online but not of uploaded files, like PDF files and images.


References

0

I have a workaround using DriveApp removeFile. Note this does not delete or trash the user file, but is no longer visible in the named folder.

removeFile(child)

Removes the given file from the root of the user's Drive. This method does not delete the file, but if a file is removed from all of its parents, it cannot be seen in Drive except by searching for it or using the "All items" view.

DriveApp.getFolderById(DriveApp.getFolderById(folderId)).removeFile(DriveApp.getFileById(fileId))

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.