I shared a folder containing files and subfolders with files with multiple users and gave them edit permissions. One users account has modified the viewing ability(?) of every file and subfolder they had access to. From my account when I open the top level folder I see it empty but I know these files are still there because I own the majority of them and my drive storage amount hasn't changed.
The user claims they have no idea how it happened so maybe that it was an app they unknowingly gave drive access to?
Is there any way I can fix this from the Google Drive web interface? I found Google Apps Scripts has access to the Drive API, should I find a script that can mass change the permissions?
Only the owner can delete the file.
The files were removed from the folder but were not deleted.
Therefore, they take up disk space.
To view files outside the folder, follow these steps:
https://drive.google.com/drive/search?q=is:unorganized%20owner:me
Excuse my bad English
Venca
Recently, I gained access to Google Team Drive via Google's Team Drive early adopter program.
I created a Google Docs file called Hello, world!, and then wrote a short Google Apps Script function which uses an addFile() method to update which Google Drive folder the file is attached to:
function move_or_link_file() {
var source = DriveApp.getFolderById("<sourceID>");
var fileiter = source.getFilesByName("Hello, world!");
var dest = DriveApp.getFolderById("<destID>");
while (fileiter.hasNext()) {
var file = fileiter.next();
dest.addFile(file);
}
}
Typically, a Google Drive folder has a URL which matches the following pattern: https://drive.google.com/drive/folders/<alphanumericID>. Although it's perhaps a bit inelegant, I can test my code under various operating scenarios and conditions by simply opening different combinations of Google Drive folders in a web browser, selecting the <alphanumericID> portion of the folder URL, and then manually copy-and-pasting values for this string into <sourceID> and <destID>.
After testing, I am able to identify four different input conditions which result in three distinct behaviors:
Case 1: <sourceID> and <destID> are both folders in my personal Google Drive:
In this case, the script behaves in effect as if it's creating a symbolic link: the Hello, world! file now appears in both directories. Note that it really is the same file, not two identical copies: for example, if I open the document, then the document URL, like the folder URLs, also follows a pattern: https://docs.google.com/document/d/<documentID>/edit. I can tell the file is the same because when I open it, the URL for the document shares the same <documentID>, regardless of which parent folder I use to access it.
For case 1, I can also get the script to behave more like a mv command by simply appending an additional line, source.removeFile(file); to the end of the file iterator loop.
Case 2: <sourceID> is a folder in my personal Google Drive while <destID> is a folder in a Team Drive:
In this case, the script behaves like a mv command by default, rather than as a symbolic link, even without the additional call to the removeFile() method that I mentioned in case 1: i.e., the Hello, world! file simply disappears from my personal drive and reappears in the Team Drive.
Case 3: <sourceID> and <destID> are both folders in a Google Team Drive:
This results in an error message from Google Apps Script: Cannot use this operation on a Team Drive item. (line 7, file "move_or_link_file").
Case 4: <sourceID> is a folder in a Team Drive while <destID> is a folder in my personal Google Drive:
Same error as for Case 3.
Now here is the really weird part: the GSuite graphical user interface (i.e., what you are using when you access Google Drive files and folders via the web browser) offers a Move command via a popup window that appears when you right-click on a file. This GUI version of the Unix-like mv command behaves identically for all four of the above cases: it doesn't matter whether you are moving a folder back and forth between a personal drive or team drive, or internally within a drive, it works correctly and moves the file to where you would expect it to go, every time.
So, I presume it must be possible to implement a mv command via Google's API, somehow, given that they've evidently done it already for users of the GUI interface.
Thus my question: given that it's empirically possible to move files back and forth between arbitrary combinations of folders in personal drives and team drives, how would I actually do it, using only the API calls provided by Google Apps Script?
Also, a bonus question: suppose that, similar to Case 1, instead of moving a file between two different folders in the same Team Drive, I actually wanted to create a symbolic link attaching the file to both folders--how would I use the Google API to do that as well? (I.e., how can I get Case 3 to behave more like Case 1?)
The Google Team Drives only recently started allowing scripts in general. I would imagine the file move you were able to achieve in case 2 is not even intended. There are still several limitations on the team drive (for example you cannot move folders).
For Case 1 I can simply point out that your script is not actually a move command. You should actually imagine Google Drive folders as Gmail tags. A file can have no folders at all. Your script merely assigns a tag to the file and as such it can appear in many folders (just like an email can have many Gmail tags and appear in each tags "folder").
It works in case 2 because Team Drive is a seperate entity from your personal drive. In essence, when you added it to the team drive you had to give up the ownership of the file. As far as I have seen, team drive considers that adding a file to it means that it should be removed from all other parents. I would assume that is why in cases 3 and 4 you cannot move any items. The owner is the team drive itself, however the commands are being sent as a regular Gsuite user.
Drive REST api was recently (~begining of March) updated to work with team drives: https://developers.google.com/drive/v3/web/about-teamdrives so I believe that technically what you are looking for can be done, however considering there are still several limitations on team drives, I don't think it will be documented as well as it could be.
I got some Google Drive folders shared with me by a collaborator, I put a lot of files into it and we did work like this for months now.
This guy did a delete on the folder and now my files are all lost, I can make a search for my files but there are so many and I don't know the names of all those files.
Is there a way to make a search on those files not listed in any folders but owned by me?
in your drive, search for
is:unorganized owner:me
https://support.google.com/a/answer/6008339?hl=en
Had the EXACT same problem. Found this thread by Googling, but had a harder time finding a complete solution. Found it here from Ally Marie:
https://productforums.google.com/forum/#!topic/docs/xOvsElpcPZA
Synopsis: You can get a list of everything you own and look for the item in that list. Click the down arrow in the Google Drive search box and select Ownership > Owned by me.
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.
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