Google Drive API: list files with no parent

前端 未结 6 1000
旧时难觅i
旧时难觅i 2020-12-30 08:47

The files in Google domain that I administer have gotten into a bad state; there are thousands of files residing in the root directory. I want to identify these files and mo

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 09:28

    In Java:

    List result = new ArrayList();
    Files.List request = drive.files().list();
    request.setQ("'root'" + " in parents");
    
    FileList files = null;
    files = request.execute();
    
    for (com.google.api.services.drive.model.File element : files.getItems()) {
        System.out.println(element.getTitle());
    }
    

    'root' is the parent folder, if the file or folder is in the root

提交回复
热议问题