How to view the parent folder of a Google Document?

Often I have the direct link to a Google Document (mine or an organizational shared one) and want to find documents that are stored within the same folder. To do so, I would need to determine the folder the document is in. Is there a way to do that?

23.1k 16 16 gold badges 105 105 silver badges 195 195 bronze badges asked May 6, 2013 at 14:15 1,821 2 2 gold badges 11 11 silver badges 7 7 bronze badges

13 Answers 13

A document can potentially be in multiple folders, but you can get a list of them through the UI.

Click the folder icon next to the document title. If the document is in a single folder, you get a view into that single folder showing the folder name with an icon to open the folder in a new tab, other documents in the folder, and options to move the current document:

enter image description here

If the document is in more than one folder, you get a list of the folders it is in with hyperlinks to each.

Screenshot of two parent folders

820 2 2 gold badges 13 13 silver badges 26 26 bronze badges answered May 7, 2013 at 23:14 1,566 1 1 gold badge 11 11 silver badges 8 8 bronze badges

I remember this "folder icon" being there a while back, but it is gone now. Anyone know how to find the parent folder in the new design?

Commented Oct 24, 2013 at 18:20

The "This item is in:" text has now moved to the dialog that appears after you click on the "folder icon". Unfortunateyl, this doesn't appear to work for files you haven't created.

Commented May 4, 2015 at 14:24 Google Drive's UI is such a mess… Commented Oct 13, 2015 at 1:39

@Jangari Yes, as nonsensical as it is, you get hyperlinks if the document is in multiple folders, but no hyperlink if the document is only in one folder. I'd encourage you to submit this product feedback to Google. Maybe they will change it if they get enough feedback of the sort. google.com/tools/feedback/intl/en

Commented Jun 26, 2017 at 15:55 The folder icon is only visible if you have permission to move the file. Commented Dec 3, 2019 at 10:15

Update: Folder icon has now changed to a move icon, but it still works.

enter image description here

answered May 1, 2020 at 10:03 Jesper Wilfing Jesper Wilfing 461 4 4 silver badges 2 2 bronze badges

Missing the Folder Icon?

If you find that little folder missing to the right of the file name, then you can choose File > Document details. to at least see the parent directory name. E.g.:

When the little folder icon is missing.

I found myself in world-2!

And you'll find where the hell Waldo is.

answered Dec 3, 2016 at 16:45 369 3 3 silver badges 4 4 bronze badges

Alas, this seems to be broken, as well. I just opened that menu item and all I see for the document I had open was Location - .

Commented Jul 27, 2021 at 3:01

As of 2014-04-04, there are a couple of ways to get from a document to its containing folder.

From the open document, click the folder icon next to the document's title. A dialog appears with "This item is in" and the containing folder name. The folder name is linked to the folder. If a "Move to" dialog appears instead, the document's containing folder is the root. If it's your document or you've explicitly added it, it's in My Drive. If not, try More -> All Items in the folder list at the left of the document list view.

From the document search view, select the item. More -> Details and activity -> Details -> Folders . Any folder names listed are linked to the corresponding folders.

As of 2014-12-03, I can no longer figure out how to get from a file view to its containing folder, for files that are not collaborative Google documents. Please comment or edit this answer if you know how.

468 1 1 gold badge 3 3 silver badges 18 18 bronze badges answered Apr 4, 2014 at 14:14 Matt McClure Matt McClure 961 7 7 silver badges 4 4 bronze badges

Google is moving away from their previous model where files and folders could have multiple parents. When they introduced Shared Drives for teams there could only be one parent and My Drive is migrating no longer allowing new parents to be added.

The UI has since then been updated to work with Shortcuts instead of multiple parents.
Below I will show how to access both the file location and all shortcut locations.

The UI is different whether you have edit permission or not to the file.

File location (view only permission)

Search for the file title in Drive

Search Query: title:Contributor

Shortcut locations (no previous shortcuts)

When there's no previous shortcuts the folder icon is missing.

Missing Folder icon. Add a shortcut to drive

Shortcut locations (with existing shortcuts)

Add another shortcut

File location (edit permission)

When you have edit permissions the UI is slightly different.

Move file dialog

Shortcuts

The menu looks different whether there exist previous shortcuts or not. This is important when guiding someone that they might see any of these.

Without and with previous shortcuts

Although the dialog showing the shortcut looks like it's coming from the Folder icon, you can't open it by clicking the icon, you must open it from the File menu as seen above.

Shortcuts dialog

answered Apr 18, 2021 at 20:05 300 4 4 silver badges 9 9 bronze badges

Let's provide a means to go to the document's parent folder with a click of the mouse.

Place the script below in your document's 'container-bound' script editor. Do this by opening your document and then from the document menu bar, select Tools > Script editor.

If this is your first time editing that document's script, default code will populate the editor's screen. Simply replace the script content with the code below. Include both the function onOpen() and listParentFolders() listed below.

Save the script in the editor and then 'refresh' the browse window displaying the associated document. A new menu item will appear for the document named Utils. Clicking on the Utils Menu pad will display the menu popup, Show Path. This script will display the directory path as a list of hyperlinks.

function onOpen() < // Add a menu with some items, some separators, and a sub-menu. DocumentApp.getUi().createMenu('Utils') .addItem('Show Path', 'listParentFolders') .addToUi(); >function listParentFolders() < var theDocument = DocumentApp.getActiveDocument(); var docID = theDocument.getId(); var theFile = DocsList.getFileById(docID); var parents = theFile.getParents(); // No folders if ( parents == null ) return; var folder = parents[0]; var folderName = folder.getName(); var folderURL = folder.getUrl(); var folders = [[folderName,folderURL]]; while (folderName != "Root")< parents = folder.getParents(); folder = parents[0]; folderName = folder.getName(); folderURL = folder.getUrl(); folders.unshift([folderName,folderURL]); >var app = UiApp.createApplication().setTitle("Folder Hierarchy").setHeight(250).setWidth(300); var grid = app.createGrid(folders.length, 1).setStyleAttribute(0, 0, "width", "300px").setCellPadding(5); var indentNum = 0, link; for (var fldCntr = 0; fldCntr < folders.length; fldCntr++)< folderName = folders[fldCntr][0]; folderURL = folders[fldCntr][1]; link = app.createAnchor(folderName, folderURL).setId("id_" + fldCntr).setStyleAttribute("font-size", "10px"); grid.setWidget(indentNum, 0, link); indentNum += 1; >app.add(grid); DocumentApp.getUi().showSidebar(app); > 
468 1 1 gold badge 3 3 silver badges 18 18 bronze badges answered Oct 25, 2013 at 0:53 51 1 1 silver badge 1 1 bronze badge

AFAIK no, there is no way to do this from the document URL or the document itself. You'd need to grab the title of the doc and search for it in your Drive list view. The search results should show you the document title, then also show the name of the parent folder in gray.

answered May 6, 2013 at 16:07 OnenOnlyWalter OnenOnlyWalter 7,414 1 1 gold badge 34 34 silver badges 48 48 bronze badges

Parent folder

I wrote a little script that retrieves the parent folder, based on the key of the document:

function doGet() < // create app and grid var app = UiApp.createApplication(); var grid = app.createGrid(4,2); // set labels for first column grid.setWidget(0, 0, app.createLabel("Add document key: ") .setStyleAttribute('fontWeight', 'bold')); grid.setWidget(2, 0, app.createLabel("Parent Folder: ") .setStyleAttribute('fontWeight', 'bold')); // set text boxes for second column grid.setWidget(0, 1, app.createTextBox().setId("key") .setName("key").setWidth(500)); grid.setWidget(2, 1, app.createTextBox().setId("path") .setName("path").setWidth(500)); // create button and handler grid.setWidget(3, 0, app.createButton("PATH") .addClickHandler(app.createServerHandler("getPath") .addCallbackElement(grid))); // add grid to application and show app app.add(grid); return app; >function getPath(e) < // get active application and key var app = UiApp.getActiveApplication(); var key = e.parameter.key; // Get file and path var path; try < var file = DocsList.getFileById(key); path = file.getParents()[0].getName(); >catch(e) < path = "file not found"; >// add path to application and update app app.getElementById("path").setValue(path); return app; > 

It looks like this

enter image description here

To install

  1. goto script.google.com, while logged in
  2. start a new script
  3. paste code and press the bug icon. Press authorize.
  4. under file>menaged version save the script.
  5. goto Publish>Deploy as web app and press update
  6. the url presented (exec at the end) will allow you to run the stand-a-lone script.

Note

Only the parent folder is mentioned (exactly what you wanted) but it will not disclose the full path.

answered May 7, 2013 at 21:13 23.1k 16 16 gold badges 105 105 silver badges 195 195 bronze badges

Here is a more complete and reliable implementation of the two scripts in these answers (first one and second one) to this question. This script allows you to paste the full URL of the file or the file ID into the first edit box in the dialog and then returns a text representation of the path as well as a link to the parent directory. The installation instructions are identical to what is shown above by Jacob, I copied them below for completeness.

NOTE: Some of the APIs used in all of these scripts are now obsolete. They are still working as of when this post was made, but will probably stop working in the future.

// // Take a Google Drive file URL or ID and output a string representation of the path as well as a link // to the parent folder // // Based on https://webapps.stackexchange.com/questions/43881/how-to-view-the-parent-folder-of-a-google-document function doGet() < // create app and grid var app = UiApp.createApplication(); var grid = app.createGrid(5,2); // set labels for first column grid.setWidget(1, 0, app.createLabel("URL or file ID: ").setStyleAttribute('fontWeight', 'bold')); grid.setWidget(2, 0, app.createLabel("Folder Path: ").setStyleAttribute('fontWeight', 'bold')); grid.setWidget(3, 0, app.createLabel("Folder URL: ").setStyleAttribute('fontWeight', 'bold')); // set text boxes for second column grid.setWidget(1, 1, app.createTextBox().setId("key").setName("key").setWidth(1000)); grid.setWidget(2, 1, app.createTextBox().setId("path").setName("path").setWidth(1000)); grid.setWidget(3, 1, app.createAnchor("","").setId("url").setName("url").setWidth(1000)); // create button and handler grid.setWidget(4, 0, app.createSubmitButton("Find") .addClickHandler(app.createServerHandler("listParentFolders") .addCallbackElement(grid))); // add grid to application and show app app.add(grid); return app; >// // getIdFromUrl - Get the file id portion of the url. If the file id itself is passed in it will match as well // // From http://stackoverflow.com/questions/16840038/easiest-way-to-get-file-id-from-url-on-google-apps-script // This regex works for any google url I've tried: Drive url for folders and files, Fusion Tables, Spreadsheets, // Docs, Presentations, etc. It just looks for anything in a string that "looks like" a Google key. That is, any // big enough string that has only (google key) valid characters in it. // // Also, it works even if it receives the ID directly, instead of the URL. Which is useful when you're asking // the link from the user, as some may paste the id directly instead of the url and it still works. function getIdFromUrl(url) < return url.match(/[-\w]/); > function listParentFolders(e) < var app = UiApp.createApplication(); var key = getIdFromUrl(e.parameter.key); var theFile = DriveApp.getFileById(key); var parents = theFile.getParents(); var fileName = theFile.getName(); // no folders if ( parents == null ) < app.getElementById("path").setValue('Unknown file'); return app; >var url; var folder; var folderName; var path; // traverse the list of parents of folders to build the path while (parents.hasNext()) < folder = parents.next(); folderName = folder.getName(); // on the first pass get the URL of the folder which is the parent folder of the file if (url == null) url = folder.getUrl(); // build up a string version of the path if (path == null) path = folderName; else path = folderName + ' / ' + path; // get the parent of the current folder parents = folder.getParents(); >app.getElementById("path").setValue(path); app.getElementById("url").setHref(url).setText(url); return app; > 

It looks like this:

Find parent folder UI

To install:

  1. goto script.google.com, while logged in
  2. start a new script
  3. paste code and press the bug icon. Press authorize.
  4. under file>menaged version save the script.
  5. goto Publish>Deploy as web app and press update
  6. the url presented (exec at the end) will allow you to run the stand-a-lone script.