Linking from JDex to Google Drive

I’m just getting my LAS set up and probably spending too much time on initial system optimization. My setup: JDex on Obsidian, primary file system on Google Drive. The challenge I’m seeking to solve: linking to my file system directly from my JDex.

I’ve figured out system that I think will work for this and wanted to share. In each Obsidian note header, I’ve added two links: the :link::open_file_folder: opens the file folder and the :link::globe_with_meridians: opens Google Drive. Here is an example:

Linking to a File Folder :link::open_file_folder:

I primarily use Windows and find managing files with File Explorer is more efficient for me. I use the Google Drive app to access GDrive in File Explorer. To create a link directly to a folder, it must:

  • begin with file:///
  • followed by the full path
  • and be URL encoded (e.g. the backslash \ is encoded as %5C)

So a link to C:\Users\Johnny\Documents would be file:///C%3A%5CUsers%5CJohnny%5CDocuments.

Linking to Google Drive :link::globe_with_meridians:

These links will open the web-based Google Drive or open the Google Drive app (only tested on iOS), which is handy when I’m using my phone. To create a link to GDrive, it must:

  • begin with https://drive.google.com/drive/folders/
  • followed by the folder ID (the long alphanumeric string of the URL directory, everything to the right of the last forward slash / in the URL bar)

Systematically Creating These Links

Here is where the magic happens. Using Apps Script in Google Sheets, you can automatically generate a full list of your folders, including folder name, folder ID, and path. Here is the script for anyone who is interested. Instructions:

  1. Create a new Google spreadsheet and in cell B2, paste the top-level folder ID (see above on how to get the folder ID).
  2. Go to Extensions > Apps Script.
  3. In the newly opened Apps Script tab, delete the default “function myFunction()…" and paste in this script.
  4. Save the script and click “Run”. The first time you do this, Google will ask you to approve permissions.

Once the script ran, I used formulas to build the links and Obsidian markdown. I then copied-and-pasted these throughout my JDex.

2 Likes