Add Google App Script to all sheets in a folder

4,190 views
Skip to first unread message

Bradley Burton

unread,
Apr 15, 2023, 4:49:58 PM4/15/23
to Google Apps Script Community
I need to add a Google App Script (my code.gs file that contains more than one function) to all files in a folder. Is there a way to do this to all the spreadsheets in the folder at once or do I need to go into each spreadsheet at paste the code?

Thank you

Nerio Villalobos

unread,
Apr 17, 2023, 12:08:44 AM4/17/23
to google-apps-sc...@googlegroups.com
Yes, it's possible to add a Google Apps Script file to all spreadsheets in a folder at once using Google Apps Script.

Here are the steps you can follow:

Open the Google Drive folder that contains the spreadsheets you want to add the script to.

Open one of the spreadsheets in the folder and go to the "Tools" menu, then select "Script editor".

In the script editor, click on "File" and select "Make a copy". This will create a new copy of the script file that you can use for all the other spreadsheets in the folder.

Give the new script file a name, and then close the script editor window.

Go back to the Google Drive folder that contains the spreadsheets you want to add the script to, and select all the spreadsheets by holding down the "Shift" key while clicking on each file.

With all the spreadsheets selected, click on the "More actions" button (the three vertical dots) and select "Google Apps Script".

This will open a new script editor window for all the spreadsheets at once. In the script editor, click on "File" and select "Add a script file".

In the "Add a script file" dialog box, enter the name of the script file you created in step 3 and click on "Add".

You should now see the new script file added to all the spreadsheets in the folder. You can now modify the code in the script file to suit your needs.

Once you have finished editing the code, save the changes and close the script editor window.

That's it! The script file should now be added to all the spreadsheets in the folder, and any changes you make to the code will be automatically applied to all the spreadsheets.

Regards,


El sáb, 15 abr 2023 a la(s) 17:50, Bradley Burton (burtonb...@gmail.com) escribió:
I need to add a Google App Script (my code.gs file that contains more than one function) to all files in a folder. Is there a way to do this to all the spreadsheets in the folder at once or do I need to go into each spreadsheet at paste the code?

Thank you

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/64478ab8-5f37-4c09-b335-aef879548464n%40googlegroups.com.


--
__________________________
Nerio Enrique Villalobos Morillo
Buenos Aires, Argentina

Bradley Burton

unread,
Apr 17, 2023, 9:23:21 PM4/17/23
to Google Apps Script Community
Thank you for the response. This is something I did try to do previously. I asked ChatGPT and it told me to do this exact same thing, but there is no "Google Apps Script" option for me when I click "More Actions." I assumed ChatGPT was just wrong (which was why I didn't mention that I tried it), so now I'm confused as to why I'm not seeing it. I followed your directions exactly, but it's not there for me. Is there something I'm missing? Could you confirm that you actually are seeing this on your end (not accusing you, but I'm not familiar with anyone here and just want to be sure that you didn't just copy ChatGPT instructions without checking). I tried searching online but can't find information about this.

Thank you.

MinhHoang To

unread,
Apr 18, 2023, 3:47:03 AM4/18/23
to Google Apps Script Community
@Bradley: That guy Nerio was blocked. I wasted my time to follow his instructions on my question.

We should report him on LinkedIn :D

Web Dev

unread,
Apr 18, 2023, 8:28:38 PM4/18/23
to Google Apps Script Community
You can create a library and include it in your Sheets.
Reply all
Reply to author
Forward
0 new messages