Create a Folder and File in Google Drive from Google Sheets
This Google Apps Script creates a folder and a file in Google Drive based on names you specify in a Google Sheet. It then saves the URLs of the folder and file back to the sheet. Follow these steps to use it:
- Open your Google Sheet.
- In Sheet2, enter the desired folder name in cell
B2
(e.g., "MyFolder") and the file name in cellB3
(e.g., "MyFile.txt"). - Click on Extensions > Apps Script in the top menu.
- In the Apps Script editor, paste the code below.
- Update
Sheet2
in the code to match your sheet's name if it's different. - Save the script with a name (e.g., "CreateFolderFile").
- Run the script by clicking the play button in the Apps Script editor. Grant permissions when prompted (you may need to authorize access to Google Drive).
- Check your sheet: The folder URL will appear in
C2
, the file URL inC3
, and a pop-up will confirm success.
Note: Ensure you have a sheet named "Sheet2" (or update the code to match your sheet name).
No comments:
Post a Comment