How to delete a File in Google Drive?

后端 未结 5 669
既然无缘
既然无缘 2020-12-31 03:57

How do I write a Google Apps Script that deletes files?

This finds files:

var ExistingFiles = DocsList.find(fileName);

But Do

5条回答
  •  死守一世寂寞
    2020-12-31 04:15

    Now you may use the following if the file is as a spreadsheet, doc etc.:

     DriveApp.getFileById(spreadsheet.getId()).setTrashed(true);
    

    or if you already have the file instead of a spreadsheet, doc etc. you may use:

    file.setTrashed(true);
    

提交回复
热议问题