Minimal Google Drive CLI for listing, searching, uploading, and downloading files.
npm install -g @mariozechner/gdcli
Before adding an account, you need OAuth2 credentials from Google Cloud Console:
Then:
gdcli accounts credentials ~/path/to/credentials.json
gdcli accounts add you@gmail.com
You can reuse credentials from gmcli or gccli:
gdcli accounts credentials ~/.gmcli/credentials.json
gdcli accounts <action> Account management
gdcli <email> <command> [options] Drive operations
gdcli accounts credentials <file.json> # Set OAuth credentials (once)
gdcli accounts list # List configured accounts
gdcli accounts add <email> # Add account (opens browser)
gdcli accounts add <email> --manual # Add account (browserless, paste redirect URL)
gdcli accounts remove <email> # Remove account
List files in a folder (default: root).
gdcli <email> ls [folderId] [options]
Options:
--max <n> - Max results (default: 20)--page <token> - Page token for pagination--query <q> - Drive query filterExamples:
gdcli you@gmail.com ls
gdcli you@gmail.com ls 1ABC123 --max 50
gdcli you@gmail.com ls --query "mimeType='image/png'"
Full-text search across all files.
gdcli <email> search <query> [--max N] [--page TOKEN]
Example:
gdcli you@gmail.com search "quarterly report"
Get file metadata.
gdcli <email> get <fileId>
Download a file. Google Docs are exported as PDF/CSV.
gdcli <email> download <fileId> [destPath]
Default destination: ~/.gdcli/downloads/
Examples:
gdcli you@gmail.com download 1ABC123
gdcli you@gmail.com download 1ABC123 ./myfile.pdf
Upload a file.
gdcli <email> upload <localPath> [options]
Options:
--name <n> - Override filename--folder <folderId> - Destination folderExamples:
gdcli you@gmail.com upload ./report.pdf
gdcli you@gmail.com upload ./report.pdf --folder 1ABC123 --name "Q4 Report.pdf"
Create a folder.
gdcli <email> mkdir <name> [--parent <folderId>]
Example:
gdcli you@gmail.com mkdir "New Folder" --parent 1ABC123
Delete a file (moves to trash).
gdcli <email> delete <fileId>
Move a file to a different folder.
gdcli <email> move <fileId> <newParentId>
Rename a file or folder.
gdcli <email> rename <fileId> <newName>
Share a file or folder.
gdcli <email> share <fileId> [options]
Options:
--anyone - Make publicly accessible (anyone with link)--email <addr> - Share with specific user--role <r> - Permission level: reader (default) or writerExamples:
gdcli you@gmail.com share 1ABC123 --anyone
gdcli you@gmail.com share 1ABC123 --email friend@gmail.com --role writer
Remove a permission from a file.
gdcli <email> unshare <fileId> <permissionId>
Get permission IDs with permissions command.
List permissions on a file.
gdcli <email> permissions <fileId>
Print web URLs for files.
gdcli <email> url <fileIds...>
All data is stored in ~/.gdcli/:
credentials.json - OAuth client credentialsaccounts.json - Account tokensdownloads/ - Downloaded filesnpm install
npm run build
npm run check
MIT
2 commits
TypeScript
56.8%
JavaScript
41.5%
Shell
1.7%
Minimal Google Drive CLI for listing, searching, uploading, and downloading files.
npm install -g @mariozechner/gdcli
Before adding an account, you need OAuth2 credentials from Google Cloud Console:
Then:
gdcli accounts credentials ~/path/to/credentials.json
gdcli accounts add you@gmail.com
You can reuse credentials from gmcli or gccli:
gdcli accounts credentials ~/.gmcli/credentials.json
gdcli accounts <action> Account management
gdcli <email> <command> [options] Drive operations
gdcli accounts credentials <file.json> # Set OAuth credentials (once)
gdcli accounts list # List configured accounts
gdcli accounts add <email> # Add account (opens browser)
gdcli accounts add <email> --manual # Add account (browserless, paste redirect URL)
gdcli accounts remove <email> # Remove account
List files in a folder (default: root).
gdcli <email> ls [folderId] [options]
Options:
--max <n> - Max results (default: 20)--page <token> - Page token for pagination--query <q> - Drive query filterExamples:
gdcli you@gmail.com ls
gdcli you@gmail.com ls 1ABC123 --max 50
gdcli you@gmail.com ls --query "mimeType='image/png'"
Full-text search across all files.
gdcli <email> search <query> [--max N] [--page TOKEN]
Example:
gdcli you@gmail.com search "quarterly report"
Get file metadata.
gdcli <email> get <fileId>
Download a file. Google Docs are exported as PDF/CSV.
gdcli <email> download <fileId> [destPath]
Default destination: ~/.gdcli/downloads/
Examples:
gdcli you@gmail.com download 1ABC123
gdcli you@gmail.com download 1ABC123 ./myfile.pdf
Upload a file.
gdcli <email> upload <localPath> [options]
Options:
--name <n> - Override filename--folder <folderId> - Destination folderExamples:
gdcli you@gmail.com upload ./report.pdf
gdcli you@gmail.com upload ./report.pdf --folder 1ABC123 --name "Q4 Report.pdf"
Create a folder.
gdcli <email> mkdir <name> [--parent <folderId>]
Example:
gdcli you@gmail.com mkdir "New Folder" --parent 1ABC123
Delete a file (moves to trash).
gdcli <email> delete <fileId>
Move a file to a different folder.
gdcli <email> move <fileId> <newParentId>
Rename a file or folder.
gdcli <email> rename <fileId> <newName>
Share a file or folder.
gdcli <email> share <fileId> [options]
Options:
--anyone - Make publicly accessible (anyone with link)--email <addr> - Share with specific user--role <r> - Permission level: reader (default) or writerExamples:
gdcli you@gmail.com share 1ABC123 --anyone
gdcli you@gmail.com share 1ABC123 --email friend@gmail.com --role writer
Remove a permission from a file.
gdcli <email> unshare <fileId> <permissionId>
Get permission IDs with permissions command.
List permissions on a file.
gdcli <email> permissions <fileId>
Print web URLs for files.
gdcli <email> url <fileIds...>
All data is stored in ~/.gdcli/:
credentials.json - OAuth client credentialsaccounts.json - Account tokensdownloads/ - Downloaded filesnpm install
npm run build
npm run check
MIT
2 commits
TypeScript
56.8%
JavaScript
41.5%
Shell
1.7%