Last active
July 30, 2023 14:11
-
-
Save extra-dev/f4995ecb73b343beb382267420a2daf3 to your computer and use it in GitHub Desktop.
Script to run inside Google Drive Scripts to create a folder system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createFolderStructure() { | |
//Create the new folder | |
var clientFolder = DriveApp.createFolder('Alice');//insert client name here inside ' ' VERY IMPORTANT FILL IN | |
//Get the master folder | |
var masterClientFolder = DriveApp.getFolderById("XXXXXXXX");//ID for Current Clients folder goes here inside " " | |
//add new folder to current client folder | |
masterClientFolder.addFolder(clientFolder); | |
DriveApp.getRootFolder().removeFolder(clientFolder); | |
//FIRST TIER// | |
//Create the new folders | |
var clientInfoFolder = DriveApp.createFolder('1. Client Info'); | |
var campaignsFolder = DriveApp.createFolder('2. Campaigns'); | |
var blogFolder = DriveApp.createFolder('3. Blog'); | |
//add new folders to new client folder and remove extra root drive folders | |
clientFolder.addFolder(clientInfoFolder); | |
DriveApp.getRootFolder().removeFolder(clientInfoFolder); | |
clientFolder.addFolder(campaignsFolder); | |
DriveApp.getRootFolder().removeFolder(campaignsFolder); | |
clientFolder.addFolder(blogFolder); | |
DriveApp.getRootFolder().removeFolder(blogFolder); | |
//SECOND TIER// | |
//CLIENT INFO// | |
var reportsFolder = DriveApp.createFolder('1. Reports'); | |
var clientSubInfoFolder = DriveApp.createFolder('2. Client Submitted Info'); | |
clientInfoFolder.addFolder(reportsFolder); | |
DriveApp.getRootFolder().removeFolder(reportsFolder); | |
clientInfoFolder.addFolder(clientSubInfoFolder); | |
DriveApp.getRootFolder().removeFolder(clientSubInfoFolder); | |
//THIRD TIER// | |
//REPORTS// | |
var tablesFolder = DriveApp.createFolder('1. Tables'); | |
reportsFolder.addFolder(tablesFolder); | |
DriveApp.getRootFolder().removeFolder(tablesFolder); | |
//CLIENT SUBMITTED INFO// | |
var brandGuidelinesFolder = DriveApp.createFolder('1. Brand Guidelines'); | |
clientSubInfoFolder.addFolder(brandGuidelinesFolder); | |
DriveApp.getRootFolder().removeFolder(brandGuidelinesFolder); | |
//SECOND TIER// | |
//BLOG// | |
var draftFolder = DriveApp.createFolder('1. Draft'); | |
var approvedFolder = DriveApp.createFolder('2. Approved'); | |
var publishedFolder = DriveApp.createFolder('3. Published'); | |
blogFolder.addFolder(draftFolder); | |
DriveApp.getRootFolder().removeFolder(draftFolder); | |
blogFolder.addFolder(approvedFolder); | |
DriveApp.getRootFolder().removeFolder(approvedFolder); | |
blogFolder.addFolder(publishedFolder); | |
DriveApp.getRootFolder().removeFolder(publishedFolder); | |
//CAMPAIGNS// | |
var campaign1Folder = DriveApp.createFolder('1. Campaign 1'); | |
campaignsFolder.addFolder(campaign1Folder); | |
DriveApp.getRootFolder().removeFolder(campaign1Folder); | |
//THIRD TIER// | |
//CAMPAIGN 1// | |
var copyFolder = DriveApp.createFolder('1. Copy'); | |
var imagesFolder = DriveApp.createFolder('2. Images'); | |
var researchFolder = DriveApp.createFolder('3. Research'); | |
campaign1Folder.addFolder(copyFolder); | |
DriveApp.getRootFolder().removeFolder(copyFolder); | |
campaign1Folder.addFolder(imagesFolder); | |
DriveApp.getRootFolder().removeFolder(imagesFolder); | |
campaign1Folder.addFolder(researchFolder); | |
DriveApp.getRootFolder().removeFolder(researchFolder); | |
//FOURTH TIER// | |
//IMAGES// | |
var jpgsFolder = DriveApp.createFolder('1. JPGs'); | |
var pngsFolder = DriveApp.createFolder('2. PNGs'); | |
imagesFolder.addFolder(jpgsFolder); | |
DriveApp.getRootFolder().removeFolder(jpgsFolder); | |
imagesFolder.addFolder(pngsFolder); | |
DriveApp.getRootFolder().removeFolder(pngsFolder); | |
//END OF SCRIPT// | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. I was wondering if this only works for Google Drive and not Google Shared Drives. I get the following error every time I try to create the my project folder inside a shared drive in google.
Exception: Cannot use this operation on a shared drive item.
createFolderStructure @ Code.gs:10