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:
- save all the original files from my application to a specific directory on my computer
- sync that folder with google drive
- have a google apps script automatically execute upon upload
- 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
- have the google apps script pattern match certain elements within the contents of the document and properly format it.
- save the document to a specific location with a specific file naming convention
- 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!