Hey everyone! I’m trying to figure out how to add the filename of my Google Doc into the document itself. I want it to update automatically whenever I change the filename. I’ve looked through the menus but can’t find an option to insert the filename as a field. Does anyone know if this is possible? If so, how can I do it? It would be super helpful for keeping track of different versions of my documents. Thanks in advance for any tips or tricks you can share!
hey liamj, i’ve been lookin for something similar. google docs doesn’t have a built-in way for this but a neat trick with google apps script can help. it’s not perfect but works. lemme know if u want more details!
I’ve actually been using a workaround that’s proven effective. While Google Docs doesn’t offer a built-in method for inserting the filename automatically, a Google Apps Script can accomplish this task. I started by going to Tools > Script editor, then pasted a script that retrieves the document’s name. Next, I created a custom menu item to run the script, which updates a designated part of the document with the current filename. Although the process isn’t entirely automatic and requires manual script execution after renaming, it has reliably supported my document version control.
As someone who’s dealt with this issue extensively, I can tell you that while Google Docs doesn’t have a native feature for this, there’s a clever workaround using Google Apps Script. I’ve implemented it in my workflow, and it’s been a game-changer.
Here’s what I did: I created a script that not only inserts the filename but also updates it automatically whenever the document is opened or edited. It’s a bit more advanced than manual execution, but it’s worth the initial setup time.
The script uses the DocumentApp.getActiveDocument() method to get the current document and its name. Then, it finds a specific placeholder text (like ‘[[FILENAME]]’) in the document and replaces it with the actual filename.
It’s not perfect - you’ll need basic scripting knowledge, and it might require some tweaking for your specific needs. But once set up, it’s quite reliable and saves a ton of time in the long run.