I've updated get photo: gam <UserTypeEntity> get photo [drivedir|(targetfolder <FilePath>)] [noshow]
drivedir specifies the value of the environment variable GAMDRIVEDIR (defaults to current working directory).
targetfolder <FilePath> specifies a user-chosen path.
noshow suppresses dumping the photo data to to stdout.
gam print users primaryemail org > userorgs.csv
Windows: gam csv userorgs.csv gam user ~primaryEmail get photo noshow targetfolder "c:\UserPhotos~~orgUnitPath~~"
Linux/Mac: gam csv userorgs.csv gam user ~primaryEmail get photo noshow targetfolder "/UserPhotos~~orgUnitPath~~"
By specifying a prefix path at the beginning of targetfolder, everyone's photo is in a subdirectory named after their org unit.
There is no leading / before the ~~ as the orgUnitPath column already has one and Windows correctly interprets / as \ in the name.
Use whatever prefix path you'd like.
I'm assuming a certain level of sanity in the naming of the org units. You can generate userorgs.csv however you'd like if you don't want all users.
Test it out, let me know if this helps,