I'm trying to modify this script so that once a day it runs exporting the result to my drive and overwriting the file that is there. I'm completely new to google scripts so this might be a very basic request. To clarify, i know how to set a tim trigger. I'm looking for how i edit the script so that it writes then overwrites the file to my drive on the timetrigger
Related
My plan is to link a google app script to my google sheets. I have 16 tabs on my google sheets. I want to make 16 app script files inside the same app script project. I also want to set time trigger on each app script to run at a certain time. My question is will every file inside the app script file will run, or only one app script will run?
The output I am looking for is that I do not have to press any button on the sheets or the app script. I want it to run each app script file at a certain time, and for the google sheets to update at that time. Each google sheet tab should update at the time they are assigned in the app script. How can I make this happen?
Thanks in advance.
Every scripts are runnable, unless the function names do not duplicate.
A project is similar to a html file, while each script file is included by <script src="name.js">
However, I doubt whether you really need one script file, or even a function for each sheet.
Of course, it depends on what you want to do. But I guess the works are similar and they could be combined into one or a few functions.
Is it possible to create a script in Google Drive that you can call or execute on any opened spreadsheets without having to keep installing the script on each opened spreadsheet?
I have data I upload to Google drive from time to time and these data comes from suppliers. I upload them to GDrive and then I do all sorts of stuffs like moving columns or adding new columns etc. I want to create a script to automate this but the problem is the script I'm creating will be attached to that spreadsheet I'm using and any new uploaded spreadsheet means I have to copy the script over to that new spreadsheet so I can run it there again.
This is kinda hard to explain but is it possible to create a script, save it on GDrive and whenever I am viewing a new spreadsheet I can run that script to do things to that spreadsheet I'm currently viewing?
I have programmed a script in a Google Sheet to treat the data stored in this script. This script runs automatically based on time.
I use a Google Sheet per month, so I make a copy of this Sheet with its programmed script every month. I modify the date and rename the file.
Nervertheless when I make the copy, it's necessary to get permissions in Google Apps Script to run the script. I would like to program a script that makes the copy, rename the file, changes the date and gets permission automatically. Making copy, renaming and changing date are easy, but I don't know how get permission automatically. Is it possible? Anyone can help me?
I have a font and alignment script which works like a charm on our daily spreadsheet. However I copy the blank file (template) 30 ish times for each month. As soon as I have done this, the font script stops working unless I go in and authorise it for each new sheet. Is there any way, maybe with the script library i can run it automatically and not have to authorise each new sheet? All users have edit access to the sheet. I have been reading and playing with the script library but can't seem to get it to work at all.
Thank you for any help.
The simplest way to authorize a script and then not need to reauthorize a derivative of it, is to not create a derivative of it. Currently, you indicate the workflow is create a copy of yesterday's document, and then everyone works on the copy.
If you reverse the order, such that you archive the copy, then you will no longer need to continually reauthorize your script in a new file, as the working file contains an authorized Apps Script project.
Create a template file, which has the corresponding sheets you would like to start each day with
Write a script which will perform 2 tasks
Export the current state of the active workbook to a new workbook (or even a PDF or other archive-ready asset)
Replace the contents of the active workbook with those from the template workbook.
Run this script either manually or from a time-based trigger.
I have been trying all day and I found this:
http://www.jellybend.com/2012/12/19/monitor-google-drive-folders-with-google-apps-script/
The attached script worked only partially for me. It doesn't respond to change to the subfolders even there are files inside the subfolders (eg. rename/delete the subfolder). It also seems to have errors if I delete and re-add the same file to the folder again, it just doesn't email me for the newly added "old file".
I also found this:
https://developers.google.com/drive/v2/reference/changes/list#examples
but unfortunately I am not really sure what those parameters are and I am just inexperienced in writing something like that.
Any help will be greatly appreciated! Thanks!
The file monitoring code at that link, is an Apps Script bound to a Sheet. An Apps Script can be bound to a Sheet, Doc, Form or Site. An Apps Script can also be a stand alone application. So, any code you may want to write, does not need to be in a spreadsheet.
An Apps Script can be set up to have a Time-driven event trigger.
There is also a Script Service to build Clock Triggers.
ClockTriggerBuilder Class
Using Time Driven Event Trigger, or a Clock Trigger you could use the getSize() method to return the amount of disk space used by the item:
Class - Folder - getSize Method
// This example logs the first file's size in bytes
// Note: This can also be used on a folder to get the size of its contents
var file = DocsList.getAllFiles[0];
Logger.log(file.getSize());
Of course, you would need to know what the original size of the folder or file was, and so you would need to store the current size somewhere. You could create a file for storing that information, or use the built in database that Apps Script has.
For storing your historical folder or file information you could use ScriptDB.
ScriptDB
Quote:
ScriptDB is a JavaScript object database for Google Apps Script. Each script project gets a database, which the script can use to save, update, and search JavaScript object data.
You could write historical file and folder info to a spreadsheet or document also.
Depending on who owns the file, and who is accessing the file, permissions would need to be granted, or you'd need to use oAuth2 to authenticate who has access to the file and folder information.
If you can't write all the code yourself, you could set up a shared Apps Script file, or find some other way to have people collaborate on the project.
I've been researching this on my own for some time and came up with a script bound to a spreadsheet as well. Hope it can help someone, as it seems that a lot of people are looking for something similar. My script is monitoring a folder and sends notification to all the current viewers of the folder as soon as there is new file added. Trigger to run the script could be set depending on the needs of the user. In my case hourly worked just fine.
Spread Sheet with the script: https://docs.google.com/spreadsheets/d/1CzVADjUTT2d9Y5OGDOnv37mCaO49kPt4RmnyZgzjTKA/edit#gid=0
If you would like to try this script just make sure you are logged in with your google account when you open the link and you should be able to make a copy of the spreadsheet.
This Google Script will send an email notification to you or other email addresses when a file in a Google Drive folder has been added, renamed, changed, or modified. http://baumbach.com/google-script-2/