Skip to content

Users Drive Cleanup

Ross Scroggs edited this page May 24, 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.

Show current drive usage.

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

Get list of top level files and folders.

GAM version 6.22.14 and higher:

gam redirect csv ./TopLevelFilesFolders.csv user user@domain.com print filelist select rootid fields id,name,mimetype

GAM version 6.22.13 and lower.

gam user user@domain.com show fileinfo root fields id
User: user@domain.com, Show 1 Drive File/Folder
  Drive Folder: My Drive (0AENlVEBUkz-hUkWXYZ)
    id: 0AENlVEBUkz-hUkWXYZ
gam redirect csv ./TopLevelFilesFolders.csv user user@domain.com print filelist select 0AENlVEBUkz-hUkWXYZ fields id,name,mimetype

Purge top level files and folders.

gam redirect stdout ./PurgeTopLevelFilesFolders.txt multiprocess redirect stderr stdout csv ./TopLevelFilesFolders.csv gam user "~Owner" purge drivefile "~id"

Get list of remaining files and folders; this list will typically be empty but will list orphans if they exist.

gam redirect csv ./OrphanFilesFolders.csv user user@domain.com print filelist fields id,name,mimetype

Purge orphan files and folders; sub files and folders will also be deleted.

gam redirect stdout ./PurgeOrphanFilesFolders.txt multiprocess redirect stderr stdout csv ./OrphanFilesFolders.csv gam user "~Owner" purge drivefile "~id"

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