列出Google Colab中googledrive内容文件夹的所有标题和ID [英] List all title + ID of a googledrive content folder in Google Colab

查看:335
本文介绍了列出Google Colab中googledrive内容文件夹的所有标题和ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于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?

解决方案

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

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

关键位:

# 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:'

Given the timing of Google Colab, I usually store my Google Drive activities in a DDMMYY folder (Day, month and year). Every day the content is stored like this. Images, code, drafts, etc.

I mount Google Drive using the default form of Google Colab and not PyDrive

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

Is there any way to generate title + ID of all folder contents of the day (DDMMYY) in a list (csv, xml or json)?

解决方案

This metadata is stored in extended file attributes. You can retrieve them using the xattr command.

Here's a complete example: https://colab.research.google.com/drive/16ylOxW_AyON1CMvjlT8rBAlDTpnR5fEa

The key bits:

# 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中googledrive内容文件夹的所有标题和ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆