My script takes 35 student names from the Sheet \'Studenti\'. Then finds the proper folder with their name (i.e. \'Smith Peter\'), removes old pdf document with old grades h
After few experiments I found the roots of the problem but not the solution. The problem with "Access denied" was related to the fact, that I was not the owner of the file created by my script and only the owner of the file may trash or delete the file. Although I was author of the script and had edit rights to the file which was placed on my drive, it did not work. On the other hand I could delete/trash the file manually without problems (and it was misleading for me).
Lesson learnt: If you allow someone else to use your script that creates a new file and also trashes the old one than you probably cannot complete your script next time sice you are not allowed (Access denied) to trash the file created by other user (although the file was created on your own drive !).
Adjusted question: Does anybody know how to write the script to trash/delete the file of which I am not the owner ( but I have edit rights) and which was created by other user on my drive?