以下のページを参考にしています。
Is there a way to get the ID of a Google Drive folder from the path using Colab?
Let's say I have a folder on GDrive with the path /content/drive/MyDrive/MyFolder. I know I can access the contents of the folder from Google Colab after mounting Drive. But is it also possible to ...
以下のように記述することで、パスからGoogle DriveのフォルダのIDを取得することができます。
# ドライブのマウント
from google.colab import drive
drive.mount('/content/drive')
# koraのインストール
!pip install kora
from kora.xattr import get_id
# 例)マイドライブへのidを取得する
path = "/content/drive/MyDrive"
fid = get_id(path)
print("https://drive.google.com/drive/u/1/folders/{}".format(fid))
以下のノートブックからもお試しいただけます。参考になりましたら幸いです。



コメント
…