How to Create Multiple Sub-folders in Google Drive Automatically
To create multiple sub-folders in Google Drive automatically, you can use Google Apps Script. Google Apps Script allows you to automate tasks within various Google products, including Google Drive. Here's a step-by-step guide to creating multiple sub-folders in Google Drive using Google Apps Script:
1. Open Google Drive:
Make sure you're logged into your Google account and open Google Drive.
2. Create a New Google Apps Script:
Click on "New" > "More" > "Google Apps Script" to open the Google Apps Script editor.
3. Write the Script:
Replace the existing code in the script editor with the following code:
function createSubFolders() {
var parentFolder = DriveApp.createFolder('Parent Folder'); // Change 'Parent Folder' to the name of your parent folder
var subFolderNames = ['Subfolder 1', 'Subfolder 2', 'Subfolder 3']; // Add the names of your sub-folders here
for (var i = 0; i < subFolderNames.length; i++) {
parentFolder.createFolder(subFolderNames[i]);
}
}
- Replace 'Parent Folder' with the name you want to give to your parent folder.
- Update subFolderNames array with the names of the sub-folders you want to create.
4. Save the Script:
Click on "File" > "Save" to save your script. Give it a name if prompted.
5. Run the Script:
Click on the play button ▶️ to run the script.
If it's your first time running the script, you might need to authorize it to access your Google Drive. Follow the prompts to do so.
6. Check Google Drive:
After the script has finished running, check your Google Drive. You should see a new parent folder with the specified sub-folders inside it.
7. Trigger Automatic Execution (Optional):
If you want this script to run automatically at specific times or events, you can set up triggers. Go to "Edit" > "Current project's triggers" and set up a trigger based on your preferences.
That's it! You've successfully created multiple sub-folders in Google Drive automatically using Google Apps Script.
0 comments:
Post a Comment