Luis Gar
Luis Gar

Reputation: 471

removeFolder doesn't work

I'm not sure what is wrong with my script.

var folderToDelete = DriveApp.getFoldersByName('folderName').next();
DriveApp.removeFolder(folderToDelete);

It doesn't show errors and the folder is not removed

It's sure the folder with name 'folderName' exists

Thanks!

Upvotes: 1

Views: 462

Answers (1)

Robin Gertenbach
Robin Gertenbach

Reputation: 10806

removeFolder just removes the folder from the root of the drive. From the documentation:

Removes the given folder from the root of the user's Drive. This method does not delete the folder or its contents, but if a folder is removed from all of its parents, it cannot be seen in Drive except by searching for it or using the "All items" view.

Are you looking for setTrashed()?

folderToDelete.setTrashed(true)

Upvotes: 2

Related Questions