Deleting Bulk Photos

887 views
Skip to first unread message

Rob

unread,
Mar 28, 2017, 1:39:08 PM3/28/17
to GAM for G Suite
I'm trying to mass delete Google User photos that they have set themselves. Instead of doing it individually, I'm trying to do it with GAM.

gam org "x/high school/users/students/2017" delete photo 

and 

gam group x...@domain.com delete photo

Both return the following error:

Getting all users in the G Suite organization (may take some time on a large domain)...
Got 184 users...
184 users are directly in the OU.
Deleting photo for x...@domain.com (1/184)

ERROR: 404: Resource Not Found: photo - notFound

Am I missing something obvious here? It appears because the first user it detects (x) for this example does not have a photo, so it errors out. Is there a way to force it to continue?

************************************

Grosse Ile Township Schools

The mission of Grosse Ile Township Schools, in cooperation with students, parents and community, is to teach the knowledge, skills and behavior necessary for each student to lead a successful life.

**Confidentiality Notice**

This email, including attachments, contains information from the sender that may be CONFIDENTIAL, LEGALLY PRIVILEGED, PROPRIETARY or otherwise protected from disclosure. This email is intended for use only by the person or entity to which it is addressed. If you are not the intended recipient, any use, disclosure, copying, distribution, printing, or any action taken in reliance on the contents of this email, is strictly prohibited. If you received this email in error, please contact the sending party by replying to this email, then delete the email from your email program.

Ross Scroggs

unread,
Mar 28, 2017, 2:54:54 PM3/28/17
to google-ap...@googlegroups.com
Rob,

You've hit one of Gam's weak spots, error handling. There is a fairly straightforward solution by using CSV files. When Gam processes a CSV file, each row is handled independently so errors in one row don't affect processing other rows.

You need to make a CSV file that contains the list of users, then you user gam to process the CSV file.

1: echo "primaryEmail" > user.csv
2: gam org "x/high school/users/students/2017"  print >> user.csv
3: gam csv user.csv gam user "~primaryEmail" delete photo

1: Create a CSV file user.csv with a single row "primaryEmail", this is the header row
2: Use the gam print command to produce the list of desired users and append to user.csv
3: Process the CSV file, each row is run in a separate process, so errors in one row don't affect other rows

As there are multiple processes running in parallel, the processing is quick.

In my advanced Gam a significant fraction of the code is handling exactly this situation. See: https://github.com/taers232c/GAMADV-X

1: gam org "x/high school/users/students/2017" delete photo 

Process each user serially, handle errors, don't stop. This solution will run slower than the CSV file solution as the file is handled serially, for small numbers of user this is probably fine.
If you want parallel processing for greater speed you can do this:

1: gam org "x/high school/users/students/2017"  print users primaryEmail > user.csv
2: gam csv user.csv gam user "~primaryEmail" delete photo

1: Create the CSV file in a single step.
2: Process the CSV file, each row is run in a separate process

If you want grate speed an a log of what happened you can do this:
1: gam org "x/high school/users/students/2017"  print users primaryEmail > user.csv
2: gam redirect stdout ./DeletePhotos.log multiprocess redirect stderr stdout csv user.csv gam user "~primaryEmail" delete photo

1: Create the CSV file in a single step.
2: Process the CSV file, each row is run in a separate process. Intelligently combine the stdout/stderr output from all of the processes into a single log file.

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-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@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/e7ace474-834b-4dc0-b3ef-dfb796ff8619%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages