问题描述
如何使用谷歌脚本永久删除谷歌驱动器上的文件
我只找到方法setTrashed。它将文件移入垃圾箱,但是如何永久移除文件 解决方案
如何使用谷歌脚本永久删除谷歌驱动器上的文件
我只找到方法setTrashed。它将文件移入垃圾箱,但是如何永久移除文件 解决方案
Apps脚本可以访问Google API,但您需要在使用它们之前明确地启用它们。
Drive API可用于删除文件。
但这是一个死路一条,因为它没有显示您拥有的Apps Script项目。
How permanently delete file on google drive using google scriptI find only method setTrashed. It moved file into Trash, but how remove file permanently
Apps Script has the ability to access Google API's, but you need to explicitly enable them before they can be used.
The Drive API, can be used to delete a file.
The Drive API method is Remove method instead of Delete.
To enable the Drive API, open the Resources menu, then choose the Advanced Google Services, and a menu will pop up. You need to click the Drive API service. Make sure that the green "ON" text is showing.
Once you've done that, you can use the auto-complete in the code editor to see what is available for methods. When you type the word "Drive" in the code editor, then enter a period, a context menu will appear. Then you can choose Files, etc.
Drive.Files.remove(fileId);
Take note of the link: Google Developers Console
You must visit your Console, and enable the services there also. And it looks like the only way you can get to your Apps Script Project in the Console is through the link in that Advanced Google Services pop up window. Going to the Google console without the correct project number in the URL fails to show your Apps Script project.
You can get to the console with:
But that is a dead end because it doesn't show the Apps Script projects that you own.
这篇关于永久删除谷歌驱动器中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!