1

I'm just new to everything about this. I created an Apps Script Project just by inside a Google Drive folder, so I did not use a Spreadsheet to create the project.

I created a function that is, when the testfile.csv file is uploaded to Folder1, it will move to Folder2. Folder1 will become empty. This function is working fine.

However, I would like the function/script to automatically run when a new testfile.csv file is uploaded again to the Folder1. The test.csv file is uploaded once a day and it can be anytime of the day--no specific time or range.

I'm afraid the "Add Trigger" built-in to the Apps Script won't work in our situation as it will keep on running depends on the set time.

Hope someone can enlighten me. Thank you!

TheMaster
  • 45,448
  • 6
  • 62
  • 85
cgstats
  • 21
  • 2
  • 1
    Pardon if I failed to understand your goal. But why you don't want a time triggered script? It can check the folder, say, every 60 seconds and to run if a new file was found inside the folder. As far as I know Drive has no "onLoad()" trigger. – Yuri Khristich Nov 05 '21 at 09:48
  • There was an instance wherein we received an error like the user account is simultaneously running script or like too many times (not the exact error message though). I was thinking this is because my other Apps Script Projects are also set to time based triggers. – cgstats Nov 05 '21 at 12:18
  • I'm not even sure if that was the cause of the error though. but, if time-based trigger should not be an issue while my other Script Projects are time-based triggers can be kept running then I think I can use the 60sec time trigger. I just really need an input from you guys who really have the knowledge about this. btw, thanks Yuri. – cgstats Nov 05 '21 at 12:25

1 Answers1

3

You'll need Drive API push notifications but sadly it can't trigger a google apps script. See a more detailed explanation here.

Your best solution is a time triggered script as what Yuri mentioned in the comments above.

NightEye
  • 10,634
  • 2
  • 5
  • 24
  • 1
    Thanks for the links. I think time trigger is really my best chance. – cgstats Nov 05 '21 at 12:26
  • No problem @cgstats. You are pretty much limited on your options. I suggest if you use time based trigger, make sure you make the frequency a little less so it won't error out since it has a limit per day. properly calculate how many times you can do your triggers daily – NightEye Nov 05 '21 at 12:38