Google Drive management - syntax errors

284 views
Skip to first unread message

Ronald Nissley

unread,
Jun 20, 2019, 2:08:06 PM6/20/19
to GAM for G Suite
I'm using GAM 4.87 and encountering some syntax errors on Drive management operations. For example:

gam user username show|print filelist select DriveFileOrFolderID


results in "ERROR: select is not a valid argument for 'gam <users> show filelist'"

Syntax documentation on the wiki doesn't offer anything on select, but I see group posts like this...

gam user username show|print filelist query "name='DriveFileOrFolderName'"

results in "ERROR: 400: Invalid query - invalid"

I resemble that remark.

gam user username show|print filelist query "title='DriveFileOrFolderName'"


returns "...Got 0 files for...", but

gam user username show|print filelist query "title contains 'DriveFileOrFolderName'"

returns "...Got 1 files for..."

Google's Drive API documentation (which the GAM Drive Management wiki links to) indicates name is a valid field and '=' is a valid operator...

Hopefully I'm missing something obvious...? Any tips/suggestions for drive management syntax, particularly around management by file/folder ID, and query syntax?

Should I downgrade to the bug-free v4.50? ;-P

Thanks in advance!

Ross Scroggs

unread,
Jun 20, 2019, 3:00:22 PM6/20/19
to google-ap...@googlegroups.com
Ronald,

Any drive command with select in it is from Advanced GAM (https://github.com/taers232c/GAMADV-XTD3)

It's somewhat confusing that you're showing the command syntax, not the actual command you're entering.

Here's the query documentation for Basic GAM: https://developers.google.com/drive/api/v2/search-files
Here's the query documentation for Advanced GAM: https://developers.google.com/drive/api/v3/search-files

Ross



--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/6deefb44-8809-4971-a80c-0b1db5ecbf2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Ronald Nissley

unread,
Jun 20, 2019, 4:09:11 PM6/20/19
to GAM for G Suite
Thank you, Ross! Consider me introduced to Advanced GAM. :-)
Sorry about the confusing sample commands. If I do something like:

gam user ronald.nissley show filelist query "name = 'Budget 2019'"

Advanced GAM, returns the expected data. With the same command, Basic GAM returns "...ERROR: 400: Invalid query - invalid."
Maybe a problem with my Basic GAM config...

Ross Scroggs

unread,
Jun 21, 2019, 12:17:25 AM6/21/19
to google-ap...@googlegroups.com
Ronald,

Advanced Gam is a super-set of Basic Gam, you can use it for all your Gam needs.
Advanced GAM uses Drive API v3, Basic GAM uses Drive API v2. In v2 a file has a title, in v3 it has a name.
This will work in Basic GAM.
gam user ronald.nissley show filelist query "title = 'Budget 2019'"
Advanced GAM accepts either the v2 names or the v3 names.

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

Ronald Nissley

unread,
Jun 21, 2019, 2:04:20 PM6/21/19
to GAM for G Suite
Thanks, Ross. That explanation was helpful. Interestingly--and partially the source of my confusion--the Valid fields for files.list table in Drive API v2 documentation only refers to a name field, not title. Other parts of the Drive API v2 documentation, including code samples, refer to title.


On Friday, June 21, 2019 at 12:17:25 AM UTC-4, Ross Scroggs wrote:
Ronald,

Advanced Gam is a super-set of Basic Gam, you can use it for all your Gam needs.
Advanced GAM uses Drive API v3, Basic GAM uses Drive API v2. In v2 a file has a title, in v3 it has a name.
This will work in Basic GAM.
gam user ronald.nissley show filelist query "title = 'Budget 2019'"
Advanced GAM accepts either the v2 names or the v3 names.

Ross

Andreu Garcia

unread,
Oct 11, 2023, 3:29:15 AM10/11/23
to GAM for Google Workspace
Hi,
I was having the same problem and I found this thread. There are examples of command line execs:

1)
$gam user myuser show filelist query "title=file.txt"
Getting files for myuser...
Owner,title,alternateLink


ERROR: 400: Invalid query - invalid
Got 0 Files for myuser...

2)
$gam user myuser delete drivefile "query.title='title.txt'"
trashing 1 files...
<HttpError 404 when requesting https://www.googleapis.com/drive/v2/files/query.title%3Dtitle.txt/trash?supportsAllDrives=true&alt=json returned "File not found: query.title=title.txt". Details: "[{'message': 'File not found: query.title=title.txt', 'domain': 'global', 'reason': 'notFound', 'location': 'file', 'locationType': 'other'}]">

3)
$gam user myuser delete drivefile "query:title='file.txt'"
Searching for files with query: "title=file.txt"...


ERROR: 400: Invalid query - invalid

4)
$gam user myuser show filelist query "title='Vacances'"
Getting files for myuser...


ERROR: 400: Invalid query - invalid
Got 0 Files for myuser...
Owner,title,alternateLink

I don't know what I'm doing wrong. Our version of GAM is:

GAM 6.22 - https://jaylee.us/gam - staticx
Jay Lee <jay...@gmail.com>
Python 3.10.5 64-bit final
google-api-python-client 2.52.0
Linux Amzn 2  x86_64
Path: /w3/httpd/execs/gam

And out final goal is to delete from all user all drive files for an specific OU. Is this possible with this version of GAM or do we need Advanced GAM?

Thank you very much

Ross Scroggs

unread,
Oct 11, 2023, 10:41:30 AM10/11/23
to google-ap...@googlegroups.com
The correct query for is: gam user myuser show filelist query "title='file.tx'"
The query is in " and the title is in '.

This should have worked: gam user myuser show filelist query "title='Vacances'"

The current version of Standard GAM is 6.58.

And out final goal is to delete from all user all drive files for an specific OU. Is this possible with this version of GAM or do we need Advanced GAM?
--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

Andreu Garcia

unread,
Oct 16, 2023, 6:42:39 AM10/16/23
to GAM for Google Workspace
Thank you Ross,

Our problem was that we launch the command through SSH to the gam server and we have to fix how it arrives
/bin/ssh ro...@gam.server -p 22'/gam/gam user myuser show filelist query "title='Vacances"'

If we directly launch it from gam server, it works.
-bash-4.2# /gam/gam user myuser show filelist query "title='Vacances"
Getting files for myuser@mydomain...
Got 1 Files for myuser@mydomain...


Now our main problem. Is there any easy way to delete all Drive Content for the users (aprox. 36K) of an OU? Like

>gam OU testOU delete drivefile query "?????" purge


1) It requieres GAMADV
2) You have to delete from user to user and generating a list of files for each user.

Thank you again for taking your time answering kindly, we really appreciate it.

Ross Scroggs

unread,
Oct 16, 2023, 11:35:38 AM10/16/23
to google-ap...@googlegroups.com
Andreu,

/bin/ssh ro...@gam.server -p 22 /gam/gam user myuser show filelist query "title='\''Vacances'\''"

That's query " title = ' \' 'Vacances' \' ' "

Advanced GAM is required.

gam config auto_batch_min 1 num_threads 20 redirect stdout - multiprocess redirect stderr stdout ou "/Path/to/OU" purge drivefile my_top_items

config auto_batch_min 1 - turn on parallel processing
# num_threads 20 - use 20 parallel processes
# redirect stdout - multiprocess redirect stderr stdout - Clean progress messages; replace - with "./deletefiles.txt" if you want a log file
# ou "/Path/to/OU" - All users is this OU will have their files deleted; use ou_and_children "/Path/to/OU" if there are sub OUs
# purge drivefile my_top_items - Purge top level files and folders; this will automatically delete sub files and folders.

Ross

----
Ross Scroggs


Ross Scroggs

unread,
Oct 16, 2023, 11:50:47 AM10/16/23
to google-ap...@googlegroups.com
Correction for ssh:

/bin/ssh ro...@gam.server -p 22 /gam/gam user myuser show filelist query \"title=\'Vacances\'\"
That's query \" title = \' Vacances \' \"

Ross
----
Ross Scroggs


Andreu Garcia

unread,
Oct 17, 2023, 5:59:56 AM10/17/23
to GAM for Google Workspace
Oh, thank you!!

Now we are going to install GAMADV in the same server we have GAM. We will have old gam in a directory and the GAMADV in a new different one.

Which kind of installation do we have to do? 
  1. Installation - First time GAM installation
  2. Installation - Update Advanced GAM
  3. Installation - Upgrading from Standard GAM <-- our scenario?
  4. Installation - Upgrading from a prior version of GAMADV-X or GAMADV-XTD
  5. Multiple Versions (You can install multiple versions of GAM and GAMADV-XTD3 in different parallel directories)
Does option 5 requiere an upgrading installation of advanced GAM? We think we should follow option 3 installation steps, but we are not sure.

Again, thank you very much!!

Ross Scroggs

unread,
Oct 17, 2023, 9:40:06 AM10/17/23
to google-ap...@googlegroups.com
Andreu,

You want 3.

Ross
----
Ross Scroggs


Andreu Garcia

unread,
Oct 19, 2023, 4:00:41 AM10/19/23
to GAM for Google Workspace
Awesome, Ross!

It worked smoothly. We tried first with 'delete', then 'untrash' and finally 'purge'

Thank you

Andreu Garcia

unread,
May 27, 2024, 2:41:33 AM5/27/24
to GAM for Google Workspace
Hi,

Does DRIVE require to be enable in the OU in order to be deleted? We did in October and we are doing the same in a different OU with DRIVE disabled and we are getting this message .

User: xxxxxxxxx, Service not applicable/Does not exist

 Is it possible to delete drive files being DRIVE disabled for that OU?

Thank you!

Andreu Garcia

unread,
May 27, 2024, 4:59:30 AM5/27/24
to GAM for Google Workspace
No problem, we activate Drive, thankfully it doesn't matter :-)

Also, if we want to delete Google Photos for all the OU, I can't find how to do it 

time ./gam config auto_batch_min 1 num_threads 20 redirect stdout - multiprocess redirect stderr "./deletephotos.txt" ou /MYOU purge photos 
Reply all
Reply to author
Forward
0 new messages