A small, agent-friendly toolkit for organizing Google Drive files.
The project is designed for workflows where a human authorizes Google Drive access, then an AI agent reads a Drive inventory and proposes or executes folder organization commands.
- Lists Google Drive files and folders into a machine-readable JSON inventory.
- Creates folders and subfolders.
- Moves files or folders by Google Drive item ID.
- Provides a
SKILL.mdguide for AI agents that operate this project. - Keeps authentication local through Google OAuth credentials.
This project is intentionally conservative: commands act on explicit Drive item IDs, not fuzzy file names, so an agent can make auditable plans before changing anything.
- Python 3.10+
- A Google Cloud OAuth client credentials file named
credentials.json - Google Drive API enabled in your Google Cloud project
- Go to Google Cloud Console.
- Create or select a project.
- Enable the Google Drive API.
- Configure the OAuth consent screen.
- If the OAuth consent screen uses the External user type, keep the app in Testing mode for personal/local use and add your own Google account under Test users. Google blocks external testing accounts that are not explicitly listed there.
- In the OAuth consent screen scopes section, add this exact scope URL:
https://www.googleapis.com/auth/drive
If the Google Cloud Console scope picker does not show it when searching for drive, paste the full URL above into the scope field. This project needs full Drive access because it lists existing files, creates folders, and moves files or folders across Drive locations.
- Create an OAuth client ID for a Desktop app.
- Download the OAuth client file.
- Save it in this project root as:
credentials.json
If Google shows "Access blocked" or says the app has not completed verification, confirm that:
- the app is still in Testing mode,
- your Google account is listed under Test users when the OAuth app user type is External,
- the exact scope
https://www.googleapis.com/auth/driveis configured in the OAuth consent screen.
If the CLI returns Google Drive API has not been used in project ... before or it is disabled, enable the Google Drive API in the same Google Cloud project used by your credentials.json:
https://console.developers.google.com/apis/api/drive.googleapis.com/overview
After enabling it, wait a few minutes and retry the command.
The first command that accesses Drive will open a browser authorization flow and create a local token.json.
Do not commit either file:
credentials.jsontoken.json
Both are ignored by .gitignore.
python -m venv .venv
source .venv/bin/activate
pip install -e .This repository includes an optional Git pre-commit hook that checks staged JSON files before a commit.
It blocks known local credential files such as credentials.json and token.json. If a staged JSON file looks like a Google Drive inventory, the hook asks for explicit confirmation before allowing the commit.
Git does not enable repository hooks automatically after clone. Install the hook once per clone:
drive-organizer-install-hooksFor intentional non-interactive commits that include Drive inventory JSON, set:
DRIVE_ORGANIZER_ALLOW_INVENTORY_JSON=1 git commitAuthorize and list your Drive:
drive-organizer list --output drive-inventory.jsonCreate a folder:
drive-organizer mkdir "Receipts"Create a subfolder inside an existing folder:
drive-organizer mkdir "2026" --parent PARENT_FOLDER_IDMove a file or folder:
drive-organizer move FILE_OR_FOLDER_ID DESTINATION_FOLDER_IDPreview a move without changing Drive:
drive-organizer move FILE_OR_FOLDER_ID DESTINATION_FOLDER_ID --dry-runRecommended flow when using this with an AI agent:
- Run
drive-organizer list --output drive-inventory.json. - Give the agent access to
drive-inventory.json,README.md, andSKILL.md. - Ask the agent to propose an organization plan.
- Review the plan before execution.
- Let the agent run explicit
mkdirandmovecommands using Drive IDs. - Run
drive-organizer list --output drive-inventory-after.jsonto verify the result.
The list command writes JSON with this shape:
{
"items": [
{
"id": "drive-item-id",
"name": "Example.pdf",
"mimeType": "application/pdf",
"parents": ["parent-folder-id"],
"webViewLink": "https://drive.google.com/...",
"modifiedTime": "2026-08-23T12:00:00.000Z"
}
]
}Folders use this MIME type:
application/vnd.google-apps.folder
- Prefer Drive IDs over names. Names are not unique in Google Drive.
- Use
--dry-runbefore moves when building or testing an agent plan. - Keep an inventory before and after a large organization pass.
- Start with a small folder or a limited query before applying broad changes.
List only folders:
drive-organizer list --query "mimeType = 'application/vnd.google-apps.folder'" --output folders.jsonList files in one folder:
drive-organizer list --query "'FOLDER_ID' in parents" --output folder-items.jsonList non-trashed PDF files:
drive-organizer list --query "mimeType = 'application/pdf' and trashed = false" --output pdfs.json.
├── README.md
├── SKILL.md
├── githooks/
│ └── pre-commit
├── pyproject.toml
└── src/
└── drive_organizer_agent/
├── __init__.py
├── cli.py
├── git_safety.py
└── google_drive.py