列出Google Colab中google驱动器内容文件夹的所有标题+ ID

问题描述 投票:0回答:1

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

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

from google.colab import drive
drive.mount('/content/gdrive',force_remount=True)

有没有办法在列表(csv,xml或json)中生成当天所有文件夹内容(DDMMYY)的标题+ ID?

python google-drive-sdk google-colaboratory
1个回答
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:'
© www.soinside.com 2019 - 2024. All rights reserved.