问题
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)?
回答1:
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:'
来源:https://stackoverflow.com/questions/55652925/list-all-title-id-of-a-googledrive-content-folder-in-google-colab