Last active
August 11, 2022 18:44
-
-
Save korakot/9bec3d134a70aa9797e17bc0adeb6663 to your computer and use it in GitHub Desktop.
Get file_id of a file on Google Drive from Colab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import getoutput | |
from IPython.display import HTML | |
!apt install xattr &>log | |
def show_link(fn): | |
fid = getoutput("xattr -p 'user.drive.id' '%s'" % fn) | |
return HTML(f"<a href=https://colab.research.google.com/drive/{fid} target=_blank>notebook</a>") | |
# using !pip install kora | |
from kora.xattr import get_id | |
get_id(fn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import getoutput | |
from IPython.display import HTML | |
from google.colab import drive | |
drive.mount('/content/drive') # access drive | |
# need to install xattr | |
!apt-get install xattr > /dev/null | |
# get the id | |
fid = getoutput("xattr -p 'user.drive.id' /content/drive/My\\ Drive/Colab\\ Notebooks/R.ipynb") | |
# make a link and display it | |
HTML(f"<a href=https://colab.research.google.com/drive/{fid} target=_blank>notebook</a>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment