Is there a Google Script that can automatically delete certain files from my Google Drive? - google-apps-script

Someone in my class (I'm keeping them anonymous) is sending me a ton of spam documents in my Google Drive. I don't know why, but I do know he has it on a script that automatically creates, sends, and deletes himself from the document. I need a script to auto-delete these files. I would do it myself, but I don't know how to code.
I have tried a couple other scripts, but none of them worked. I have deleted a ton manually, but I would like a more efficient way.

Related

Programmatically updating linked tables and charts in a Google Doc with Apps Script

I have a template Google Doc with linked tables and charts that I need to programmatically update so that I can export it as PDF and send by email. I haven't found a way to do that neither with apps script nor google docs api. And I really want to avoid updating the template with static content.
I know this question has been asked before, but never has a positive solution been found.
If this is still not possible, maybe there is a work around? Like a chrome extension you can trigger that can simulate manual update? Or whatever. Doesn't have to be elegant or anything, just has to work somehow.
Thanks a lot for your help.

Upload files to Google Drive from a Google Form

I'm not a savvy coder, so this is quite a challenge to me, but I'm trying to get this to work anyway:
I'm preparing a registration form on Google Forms. People will insert their personal data and, in the end, I would need people to be able to upload a few files (a photo, a CV, etc...). Such files would be stored on Google Drive.
Now, I've seen that there seems to be no straightforward way of doing it on Google Forms. I was thinking that my only option would be to try and get it done with Google Scripts and then embed that script inside my Google Form.
Is this possible? Can anyone help me with this?
Many, many thanks in advance!
In case you have a Google bussines account, you can create a file upload question type. See the announce here https://gsuiteupdates.googleblog.com/2016/10/five-new-ways-to-reach-your-goals.html

Prevent deletion of files in Google Drive

I am trying to prevent deletion of all files uploaded to specific folder in Google drive. The idea is several people will be able to upload files to this drive, but they should never be able to delete it.
I thought of putting a Google apps script to achieve this, like letting the script run every x interval and getTrashedFiles and set isTrashed to false. But what if the user is able to delete it from trash too?
Is there a foolproof way?
Or is Google Drive not the right answer at all?
Any other service can help me which is simple for people uploading the files?
TIA
its possible but the way you are doing it isnt practical or tamperproof.
instead write a little apps script webapp that allows uploading files to the given folder where you are owner and only writter.
publish it to run as you with permissions to anyone (or your domain). they will be able to add files and view but not change or remove them (and you will be the owner of all uploaded files).
to support uploading files already in drive (move them to the folder) is also possible but with more code.

Sharing Google Docs content-bounded scripts

I have created some content bounded scripts (Tools->Script Editor) for private use. The scripts add a sidebar, and use a timer to copy the content from the sidebar to a Google document at the cursor position. It is important that the insertion happens at the cursor.
I want to share these scripts with others, as well as add them to old documents. All suggestions I have seen so far involves creating a template document with these scripts and then sharing the template document. This option is not feasible for me. One of the concerns is, these scripts need to be added to existing documents. Creating a new document, and merging it with the old one is not working (the original documents are complex, and migrated documents loose formatting).
Is there an easy way to share/insert these scripts? So far, I have failed to implement any of the below obvious options:
Export Script Editor project to somewhere, and then import it in another document.
Create an app script in drive, and then import it in an existing document.
Publish this as add-on (N/A since this is not a public project, and not complete yet either).
I'm not sure if it is feasible to publish my scripts as a webapp, then write a simple container-bound application to call my webapp with document id as suggested at Deploying container-bound Google Apps Script as Web App
However, this requires webapp to insert the text at cursor position of the active window. I doubt that is possible.
I'm hoping that somebody found an easier way, and willing to share it.
I appreciate any help.
Sincerely,
Converting your script to an add-on is the recommended way to distribute across multiple users and documents. We understand this solution doesn't always work when the script is not meant for general consumption. Add-ons can be published only to a single domain however, so if all of your users are within a Google Apps domain then add-ons may still be an option.

Can a script automatically share Google Drive files to another email address?

Does anyone know if it would be possible to set up a script on my Google account that triggers when a new item is shared to the email and then automatically shares it with another email address?
I use a personal Gmail account, but whenever I do school work documents are always shared with my school email and it is a pain to have to share everything manually or keep switching accounts.
When I looked a few weeks back I was unable to find a way to have a script trigger on new shared items, but I am new to these scripts so if anyone has a suggestion I would appreciate it. Thanks!
I don't think you can actually triggers on new items. But you can write a script to read the Drive feed to easily check if there's new files.
Such script would still have to be triggered on a time-driven basis, so you wouldn't have "instant" access on your second account. Also, if I'd write such script, I would just create a folder, share it with the desired accounts, then use the script just to move the files to this folder. This approach has the benefit of easily allowing you to check which files are shared (with your specific account) and which aren't. And since folders are actually just labels in Drive, it is not any problem if you like or need to have your files organized in another folder structure.
By the way, have you seen Chrome users feature? It helps a lot when working with multiple accounts.