{"id":24084369,"url":"https://github.com/4trodev/drive-auto-file-organizer","last_synced_at":"2025-09-08T05:33:50.065Z","repository":{"id":268951137,"uuid":"861795732","full_name":"4troDev/Drive-Auto-File-Organizer","owner":"4troDev","description":" Google Apps Script automatically organizes files in your Google Drive based on their names.","archived":false,"fork":false,"pushed_at":"2024-09-23T15:41:08.000Z","size":6,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-31T02:57:55.445Z","etag":null,"topics":["education","google","googlescript","school"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/4troDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-23T14:24:54.000Z","updated_at":"2025-05-24T05:31:32.000Z","dependencies_parsed_at":"2024-12-21T03:01:47.884Z","dependency_job_id":null,"html_url":"https://github.com/4troDev/Drive-Auto-File-Organizer","commit_stats":null,"previous_names":["4trodev/drive-auto-file-organizer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/4troDev/Drive-Auto-File-Organizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4troDev%2FDrive-Auto-File-Organizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4troDev%2FDrive-Auto-File-Organizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4troDev%2FDrive-Auto-File-Organizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4troDev%2FDrive-Auto-File-Organizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4troDev","download_url":"https://codeload.github.com/4troDev/Drive-Auto-File-Organizer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4troDev%2FDrive-Auto-File-Organizer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274136619,"owners_count":25228412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["education","google","googlescript","school"],"created_at":"2025-01-10T00:21:08.610Z","updated_at":"2025-09-08T05:33:50.002Z","avatar_url":"https://github.com/4troDev.png","language":"JavaScript","readme":"# Drive Auto File Organizer\n\nThis Google Apps Script automatically organizes files in your Google Drive based on their names. It moves files with specific naming conventions to designated folders.\n\n## Table of Contents\n\n- [Features](#features)\n- [Getting Started](#getting-started)\n- [Usage](#usage)\n- [Code Overview](#code-overview)\n- [Auto Run](#auto-run)\n- [Examples](#examples)\n- [Deployment](#deployment)\n- [Notes](#notes)\n- [License](#license)\n\n## Features\n\n- Automatically moves Google Docs, Sheets, Slides, and Forms to specified folders based on their titles.\n- Easily configurable to add more folders and categories.\n\n## Getting Started\n\n### Prerequisites\n\n- A Google account to access Google Drive and Google Apps Script.\n\n### Installation\n\n1. **Open Google Apps Script**: Go to [Google Apps Script](https://script.google.com).\n2. **Create a New Project**: Click on \"New Project\".\n3. **Copy the Code**: Use the provided code snippet below.\n\n## Usage\n\n1. **Edit the Code**:\n   - Replace placeholder folder names and IDs in the `folders` object with your actual folder names and IDs.\n   - The folder ID can be found in the URL of the folder when opened in Google Drive.\n\n \u003cimg width=\"1128\" alt=\"Folder ID\" src=\"https://github.com/user-attachments/assets/86ac3216-7957-40c9-858c-0475cdae6115\"\u003e\n\n\n2. **Set Up Time-Driven Triggers**:\n   - Set a trigger to run this function periodically (e.g., every 10 or 15 minutes) to check for new files.\n\n## Code Overview\n\nHere's the complete code for the file mover:\n\n```javascript\nfunction moveFiles() {\n  const rootFolder = DriveApp.getRootFolder();\n  const folders = {\n    'Data 101': DriveApp.getFolderById('Folder ID here'), // Replace with actual folder ID\n    'Data 102': DriveApp.getFolderById('Folder ID here'), // Replace with actual folder ID\n    'Reports': DriveApp.getFolderById('Folder ID here'), // Replace with actual folder ID\n    // Add more folders as needed\n  };\n\n  const files = rootFolder.getFiles();\n  const movedFiles = [];\n\n  while (files.hasNext()) {\n    const file = files.next();\n    const title = file.getName();\n    const matches = title.match(/\\[(.*?)\\]/);\n\n    // Check if the file is a supported type\n    const mimeType = file.getMimeType();\n    const supportedTypes = [\n      MimeType.GOOGLE_DOCS,\n      MimeType.GOOGLE_SHEETS,\n      MimeType.GOOGLE_SLIDES,\n      MimeType.GOOGLE_FORMS,\n    ];\n\n    if (matches \u0026\u0026 supportedTypes.includes(mimeType)) {\n      const category = matches[1].trim();\n      const targetFolder = folders[category];\n\n      if (targetFolder) {\n        targetFolder.addFile(file);\n        rootFolder.removeFile(file);\n        movedFiles.push(file.getName());\n      }\n    }\n  }\n\n  Logger.log('Moved files: ' + movedFiles.join(', '));\n}\n```\n\n## Examples\n\n### Example Folder Structure\n\nSuppose you have the following folders in your Google Drive:\n\n\u003cimg width=\"1124\" alt=\"Folder Structure\" src=\"https://github.com/user-attachments/assets/2882f77f-315b-4900-8ef3-5d906d79ab3e\"\u003e\n\n*Example folder structure in Google Drive.*\n\n- **Data 101**\n- **Data 102**\n- **Reports**\n\n### Example File Naming\n\nWhen naming your files, use the format:\n\n\u003cimg width=\"1115\" alt=\"Folder Structure\" src=\"https://github.com/user-attachments/assets/4b907d92-19a2-4861-b807-d2c7611ef53d\"\u003e\n*Example of file naming convention.*\n\n- `[Data 101] - Project Proposal`\n- `[Data 102] - Budget Report`\n- `[Reports] - Quarterly Review`\n\n### Expected Behavior\n\n- When a file named `[Data 101] - Project Proposal` is added to your root folder, the script will automatically move it to the **Data 101** folder.\n- Similarly, `[Data 102] - Budget Report` will go to the **Data 102** folder.\n\n## Deployment\n\n1. **Deploy the Script**:\n   - Click on **Deploy** in the script editor.\n   - Choose **New deployment**.\n   - Select **Time-driven triggers** to run the `moveFiles` function at your desired intervals.\n\n*Steps for deploying the script.*\n\n\u003cimg width=\"730\" alt=\"Add trigger\" src=\"https://github.com/user-attachments/assets/19db7573-e99d-4663-b581-3ba6448730f3\"\u003e\n\n\n2. **Set Up Triggers**:\n   - Click on the clock icon (Triggers).\n   - Add a new trigger to run `moveFiles` based on your chosen frequency.\n\u003cimg width=\"730\" alt=\"Screenshot 2024-09-23 at 11 33 46 AM\" src=\"https://github.com/user-attachments/assets/210fce95-1754-4b35-8320-6988c44c45d7\"\u003e\n\n## Auto Run\n\n1. Click the triggers (clock icon).\n2. Add a trigger.\n3. Select event source: **Time-driven**.\n4. Select type of time-based trigger: **Hour timer**.\n5. Select hour interval: Change to your liking.\n6. Adjust failure notification settings as needed.\n\u003cimg width=\"1083\" alt=\"Auto-run\" src=\"https://github.com/user-attachments/assets/a8bfdcf5-89e4-4bbf-b686-d608cc240b9c\"\u003e\n\n## Notes\n\n- Ensure that the naming convention is consistent for the script to work correctly.\n- The script only processes files of the specified types (Docs, Sheets, Slides, Forms).\n\n\n## License\n\nThis project is open-source and free to use. You can modify it as needed for your personal or organizational use.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4trodev%2Fdrive-auto-file-organizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4trodev%2Fdrive-auto-file-organizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4trodev%2Fdrive-auto-file-organizer/lists"}