I want to make historic files read-only so that no one reading them (even me) can accidentally edit them. I'd like to make this transparent to the users, so having to open them in a different way is not a great solution.

Now, I guess I can easily do this for others when I share it (making their access View only). How do I make the file read-only even to me?


You can lock your files, but unfortunately that is not a very simple action. No one can edit the file after locking, but unlocking is relatively easy. Here are the steps you need to take (Credits to https://www.labnol.org/code/read-only-google-drive-file-201011)

  1. Get the shareable link for the file you want to lock. Right click on the file, click on the "get link" option and copy the link that you will see in the pop up menu. Set the permissions of the link to edit, otherwise the script can't lock the file.
  2. Create a new tab in your browser and go to "script.new". this will open a new Google App script.
  3. Copy the following code in the editor:
const makeFileReadyOnly = () => {
  const fileUrl = '<<FILE URL>>';
  const [fileId] = fileUrl.split('/').filter((e) => /[_-\w]{25,}/.test(e));
  UrlFetchApp.fetch(`https://www.googleapis.com/drive/v3/files/${fileId}`, {
    method: 'PATCH',
    contentType: 'application/json',
    headers: {
      Authorization: `Bearer ${ScriptApp.getOAuthToken()}`,
    payload: JSON.stringify({
      contentRestrictions: [
          readOnly: true,
          reason: 'Prevent accidental editing',
  // For requesting correct scope, do not delete
  // var file = DriveApp.getFileById().setName()
  1. Replace the <<FILE URL>> in line #2 with the URL of the Drive file that you copied in the previous step.
  2. Save project and run the function. You will be asked for permissions, accept them and the file will be locked.
  3. If you wish to unlock the file, simply right click on the file and select "unlock". You can find the script in https://script.google.com/home if you want to lock the file again.
  1. Create a new account to be used as "librarian" / "archivist"
  2. Transfer the ownership of the file to that account.

Note:The new account should have the same domain as the current owner of the file.

  • As this is a work account, I don't have the access to create new accounts. Is it really impossible to make a file read-only in Drive? I thought this was supposed to be a business-strength filesystem! This is an unbelievable restriction. – Martin Hanley Apr 6 at 6:54

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.