title: Set working directory for Google Colab notebook to Drive location of the notebook
body: <p>I'm trying to set the working directory for a Google Colab notebook to the location where the notebook resides in Google Drive without manually copying-pasting the folderpath. The motivation is to allow copies of the notebook to function in place and dynamically set the working directory to the location of the notebook without having to manually copy and paste the location to the code.</p>
  <p>I have code to mount the notebook to Google Drive and know how to set the working directory but would like to have a section of code that identifies the location of the notebook and stores it as a variable/object.</p>
  <pre><code>## Mount notebook to Google Drive
  from google.colab import drive
  drive.mount(&quot;/content/drive&quot;, force_remount=True)
  
  ## Here is where i'd like to save the folderpath of the notebook
  ## for example, I would like root_path to ultimately be a folder named &quot;Research&quot; located in a Shared Drive named &quot;Projects&quot;
  ## root_path should equal '/content/drive/Shared drives/Projects/Research'
  ## the notebook resides in this &quot;Research&quot; folder
  
  ## then change the working directory to root_path
  os.chdir(root_path)
  </code></pre>