Skip to content

Instantly share code, notes, and snippets.

@wtfaremyinitials
Last active August 8, 2016 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtfaremyinitials/11dd0ef64bd62ff537c7ca7730a37b25 to your computer and use it in GitHub Desktop.
Save wtfaremyinitials/11dd0ef64bd62ff537c7ca7730a37b25 to your computer and use it in GitHub Desktop.
Fix Orphaned Google Drive Folders

Recently my school cleared my Google Drive for the coming school year and moved the old folders to an archive folder. Unfortunately this archive folder doesn't show up in Google Drive's main list of files because it's an orphan. Currently it can only be accessed via search.

The following script will manually add a parent to any Google Drive folder, even orphaned ones. How to use it:

  • Navigate to the folder you would like to add a parent to. Copy the ID of the folder in the URL. (28 random letters and numbers)
  • Nagivate to https://script.google.com
  • Paste the script
  • Replace [snip] in the script with your folder ID.
  • Save your new Google Script project and give it any name.
  • Click the play button on the new script

fix.js

function fixDrive() {
var root = DriveApp.getRootFolder()
var archive = DriveApp.getFolderById("[snip]")
root.addFolder(archive)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment