Skip to content

Users Drive Cleanup

Ross Scroggs edited this page May 25, 2022 · 19 revisions

Users - Drive - Cleanup

API documentation

Definitions

<SharedDriveID> ::= <String>
<SharedDriveName> ::= <String>
<SharedDriveEntity> ::=
        <SharedDriveID>|(teamdriveid <SharedDriveID>)|(teamdriveid:<SharedDriveID>)|
        (teamdrive <SharedDriveName>)|(teamdrive:<SharedDriveName>)

Display empty folders on My Drive

gam <UserTypeEntity> print emptydrivefolders [todrive <ToDriveAttribute>*]

Delete empty folders on My Drive

gam <UserTypeEntity> delete emptydrivefolders

Empty the trash on My Drive

gam <UserTypeEntity> empty drivetrash

Display empty folders on a Shared Drive

gam <UserTypeEntity> print emptydrivefolders [todrive <ToDriveAttribute>*]
        select <SharedDriveEntity>

Delete empty folders on a Shared Drive

gam <UserTypeEntity> delete emptydrivefolders <SharedDriveEntity>

Empty the trash on a Shared Drive

gam <UserTypeEntity> empty drivetrash <SharedDriveEntity>

Delete contents of My Drive

The following commands will delete the contents of a user's My Drive.

This is not reversible, Think before proceeding.

Show current drive usage.

gam redirect stdout ./DrivefileUsage.txt user user@domain.com show drivesettings

Generate an initial list of files.

gam redirect csv ./InitialFileList.csv user user@domain.com print filelist fields id,name,mimetype,basicpermissions,parents fullpath showdepth orderby name

Purge top level files and folders; includes orphans.

gam config csv_input_row_filter "depth:count=0" redirect stdout ./PurgeTopLevelFilesFolders.txt multiprocess redirect stderr stdout csv ./InitialFileList.csv gam user "~Owner" purge drivefile "~id"

Generate list of remaining files and folders; this list should be empty; investigate if not.

gam redirect csv ./FinalFileList.csv user user@domain.com print filelist fields id,name,mimetype,basicpermissions,parents fullpath showdepth orderby name

Show updated drive usage.

gam redirect stdout ./DrivefileUsage.txt append user user@domain.com show drivesettings

Update History

Installation

Configuration

Notes and Information

Definitions

Command Processing

Collections

Client Access

Special Service Account Access

Service Account Access

Clone this wiki locally