Script applications have the ability to access the Google APIs, but you need to explicitly enable them before using them.
Drive API can be used to delete a file.
API Driver - Remove
API method Delete instead of Delete .
To enable the driveβs API, open the "Resources" menu, then select "Google Advanced Services" and a menu will appear. You need to click the Drive API service. Make sure that the green text "ON" is displayed.

Once you do this, you can use autocomplete in the code editor to find out what is available for the methods. When you enter the word "Disk" in the code editor, enter the period, a context menu will appear. Then you can select Files , etc.
Drive.Files.remove(fileId);
Note:
Pay attention to the link: Google Developers Console
You should visit the console and enable services there. And it looks like you can access the Apps Script project in the Console using the link in the Advanced Google Services pop-up window. Going to the Google console without the correct project number in the URL does not display the Apps Script project.
You can go to the console:
Google console
But this is a dead end because it does not show the Apps Script projects that you have.
Sandy good
source share