5

I have an interesting fairly simple problem I am trying to solve but I am at a loss on the proper code to get this to working correctly.

Basically, I have an very old local application running which allow me to print a receipt of a transaction. I have the ability to enable this receipt to be printed to a specific file within a specific directory on my computer or I can set it up to print out automatically to a printer on my computer. Currently I print the data out to a file, then copy the contents of that file and paste it into a word document template and then manually go through and format the data so it looks clean (I should note that the data prints out in fixed field format requiring a specific font and size so its pasts correctly. After all this is done I then email the word or pdf document out.

Essentially what I am trying to do here is automate this method and I thought this should be possible using a Google Apps Script.

My thought here was that it should be possible to:

  1. save all the original files from my application to a specific directory on my computer
  2. sync that folder with google drive
  3. have a google apps script automatically execute upon upload
  4. have the google apps script automatically use a specific document template I create with a header/footer and then paste all the contents from the new file which was uploaded
  5. have the google apps script pattern match certain elements within the contents of the document and properly format it.
  6. save the document to a specific location with a specific file naming convention
  7. automatically email the document as a doc or pdf based upon a specific regex matched field within the source document.

Could anyone provide a specific code example which demonstrates how Google apps scripts can be utilized to monitor the contents of a specific Google drive folder to trigger an event immediately after a new file is uploaded?

Thanks in advance!

NetConstructor.com
  • 353
  • 1
  • 7
  • 17
  • 2
    What you've mentioned is possible using Google Apps Script. You can visit the 5 minute quickstart guide ( code.google.com/googleapps/appsscript/guide.html ) to learn about apps script. If you have a specific issue, post it on SO. – Srik Aug 01 '13 at 08:28
  • updated the question to be specific - thanks – NetConstructor.com Aug 01 '13 at 12:48
  • 1
    You would be setting up a script on a time based trigger to poll the specific folder for any new files since last running. Not 'listening' for new files as such. – JSDBroughton Aug 01 '13 at 20:10
  • There really is no "event" related triggers to which a function can be assigned right after a file completes an upload successfully to google drive? I would assume if this truly is correct then the only method to hack this involves first writing a totally separate script which maintains an index of all documents... Also, if one uses time based triggers, is is possible to have scripts execute more than once every 60 seconds? – NetConstructor.com Aug 02 '13 at 00:08

0 Answers0