I'm looking for a way to create a copy of a given file in the same Google Drive directory using Google Apps Script.
The goal is to iterate through a folder structure looking for files owned by a specific user; when such a file is found [doc, spreadsheet, PDF], create a copy in the same place and delete the original.
The reason for this is that we have files owned by users in other domains and Google currently does not allows the transfer of ownership outside the domain. Using a script like this, could help us solve the problem.
Any ideas?
Thanks,
Related
I would like to allow my students to send me one or more files directly to my google drive via a form where they would just enter their name and choose the file(s) to send (drag and drop would be great). A folder with their name would be created in a specific folder on my drive and a warning email would be sent to me. Do you think this is feasible with google script? Thanks in advance.
An example here but paying ...
I've checked and Google Forms already allows for a File Upload kind of question (with drag and drop too).
It automatically creates a folder in your Google Drive (altough it doesnt create a folder for every student) (example here) and in the spreadsheet that it automatically generates there is a permanent link to that file (example here).
If that's not what you are looking for and you need the 'Folder per student' feature then yes, you can use google apps script to move files in folders quite easily.
I am working on an application which requires the automatic creation of a folder on customer's Google Drive accounts as opposed to them creating this themselves.
I will have their permission to do so and won't have access to this folder. Ideally this folder would be encrypted but they could do this afterwards themselves.
Is it possible? And if it, how can I achieve that?
It can be done using the REST API. See the section called Creating a folder.
https://developers.google.com/drive/api/v3/folder
How can I add a prefix or a suffix to all files/ folders in Google Drive using Google Script. The objective is that whenever a users needs to be deleted to add a suffix to all files and folders and transfer to another user so that the documents of the user can easily be tracked at a later stage.
Regards
The File.setName() method in the Drive Service will do what you want. I'd be happy to help further if you post a sample of your code.
Is it possible to restrict the reach of a Google Apps Script to a given Google Drive folder?
I'm creating a stand alone apps script that will be hosted as a web app.
The goal of the script is to list all the sub-folders contained inside the folder (the root folder) where the stand alone script is saved and return a JSON with information about those sub-folders and the files that they contain.
notes:
The name or the id of the root folder is unknown as the script will be distributed to Google Drive users and I want to allow them to save the script inside any folder they would like to.
Although the root folder can have any name or any hierarchical position inside the user's Google Drive folders tree, I'm planning on enforcing a predefined naming structure for the sub-folders.
I thought about two approaches to solve this, but I do not know which one is possible and what Classes and Methods to use.
1)The first approach would be to restrict the script reach to it's container folder, therefore the call to DocsList.getFolders(), would return an array of folders objects just for the folders (sub-folders) contained by the root folder.
Question: Does Google Apps Script provide a Class or Method to restrict the reach of a stand alone script, as described above?
2) Get the name or id of the root folder containing the script and using it retrieve the sub-folders and their files.
Question Does Google Apps Script provide a Method to get the name or the id of the folder that contains the script?
Thanks in advance for any help or tip.
None of those are currently possible. You can write a ui to ask the user for the folder. The google picker now supports picking folders.
I would like to use Google Drive to push files in various folders onto a remote computer. I would like this to be a one-way transaction so the people using the computer cannot write to Google Drive.
However, when I use the following C# code to get the files from Google Docs I only get the file names, not their directories where they will be on the remote computer. This won't work because some files in different directories have the same name. Is there a way to programmatically get directory information from these files?
Alternately, if I could set up the Google Drive folder to be read-only, that would accomplish my goal and probably be easier. Can this be done?
You should use the Google Drive API to list all files and check the parents field of each of them to map those files into folders:
https://developers.google.com/drive/v2/reference/files#resource