Python × Google Google Drive APIを使ってGoogleドライブの特定フォルダ内に存在する、フォルダ、ファイルの一覧を取得する方法。
#importやGoogleのOAuth2.0認証の手順は省略 def sample01(arg_folder_id): res = service.files().list( q = f"'{arg_folder_id}' in parents", fields="nextPageToken, files(id, name)" ).execute() #これでresにarg_folder_idに含まれるフォルダとファイルの一覧が含まれています。
Google Drive のフォルダIDの調べ方は以下を参照。
▼参考文献
![](https://meshilabo.xyz/wp-content/uploads/cocoon-resources/blog-card-cache/1687e386a26b0a2c850d25b50535cd30.png)
Method: files.list | Google Drive | Google for Developers
![](https://meshilabo.xyz/wp-content/uploads/cocoon-resources/blog-card-cache/1687e386a26b0a2c850d25b50535cd30.png)
Search for files and folders | Google Drive | Google for Developers
Learn more about the different methods used to search for moonrise-replace059a5502ea7740eeac3022929f2706fbmoonrise-replace files and folders.
![](https://meshilabo.xyz/wp-content/uploads/cocoon-resources/blog-card-cache/1687e386a26b0a2c850d25b50535cd30.png)
Search for files with a specific label or field value | Google Drive | Google for Developers
コメント