在 Google Colab 中列出谷歌驱动器内容文件夹的所有标题 + ID
List all title + ID of a googledrive content folder in Google Colab
考虑到 Google Colab 的时间安排,我通常将我的 Google Drive 活动存储在 DDMMYY 文件夹中(日、月和年)。每天的内容都是这样存储的。图片、代码、草稿等
我使用 Google Colab 的默认形式安装 Google 驱动器,而不是 PyDrive
from google.colab import drive
drive.mount('/content/gdrive',force_remount=True)
有没有办法在列表(csv,xml 或 json)中生成当天所有文件夹内容的标题 + ID(DDMMYY)?
此元数据存储在扩展文件属性中。您可以使用 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:'
考虑到 Google Colab 的时间安排,我通常将我的 Google Drive 活动存储在 DDMMYY 文件夹中(日、月和年)。每天的内容都是这样存储的。图片、代码、草稿等
我使用 Google Colab 的默认形式安装 Google 驱动器,而不是 PyDrive
from google.colab import drive
drive.mount('/content/gdrive',force_remount=True)
有没有办法在列表(csv,xml 或 json)中生成当天所有文件夹内容的标题 + ID(DDMMYY)?
此元数据存储在扩展文件属性中。您可以使用 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:'