列出Google Colab中googledrive内容文件夹的所有标题和ID

时间:2019-04-12 13:36:13

标签: python google-drive-api google-colaboratory

鉴于Google Colab的使用时间,我通常将我的Google云端硬盘活动存储在DDMMYY文件夹(日,月和年)中。每天内容都是这样存储的。图片,代码,草稿等。

我使用默认格式的Google Colab而不是PyDrive挂载Google云端硬盘

SHOW_VIEW(:parameter.navigation_canvas)

是否可以生成列表(csv,xml或json)中当天所有文件夹内容(DDMMYY)的标题+ ID?

1 个答案:

答案 0 :(得分:1)

此元数据存储在扩展文件属性中。您可以使用xattr命令来检索它们。

这是一个完整的示例: https://colab.research.google.com/drive/16ylOxW_AyON1CMvjlT8rBAlDTpnR5fEa

关键位:

# Installing the xattr tool.
!apt-get install -qq xattr

# Retrieving the file ID for a file in `"/content/drive/My Drive/"`:
!xattr -p 'user.drive.id' file

# Retrieving the title
!xattr -p "user.drive.itemprotostr" created.txt | grep 'title:'
相关问题