Assistance Needed with Google Apps Script - Folder Structure Copying Issue

80 views
Skip to first unread message

Otto Ontaneda

unread,
Nov 1, 2024, 11:12:09 AMNov 1
to Google Apps Script Community

Hello everyone,

I'm currently working on a Google Apps Script project where I need to copy only the folder structure (not the files) from one Google Drive folder to another. The goal is to replicate the folder hierarchy while excluding all files within those folders.

Here is the situation:

  1. Script Purpose: I am using Google Apps Script to copy just the folder names and structure from a source folder to a destination folder, maintaining the original hierarchy without transferring the files.

  2. Initial Script: The initial script worked well for a small number of folders, but I recently encountered issues due to the increased volume of folders, which led to execution time limits. I then modified the script to incorporate pauses and recursion to handle a larger folder structure.

  3. Problem: After updating the script, I'm now encountering an error where Google blocks the app, showing a message that says, “This application is blocked.” I believe the issue is related to security or authorization since I’m using ScriptApp.newTrigger() to restart the script after each pause. Here is the error message:

    • "This application tried to access sensitive information in your Google Account. To keep your account safe, Google has blocked this access."
  4. Troubleshooting: I tried the following:

    • Adjusting the script to avoid triggering security blocks.
    • Attempting different approaches for recursive copying without using triggers.
    • Running the code in segments manually to bypass time limits.

Questions:

  • Is there a more efficient way to handle a large folder structure replication with Google Apps Script without triggering security blocks?
  • Has anyone experienced similar issues with Google blocking the script for attempting to access sensitive information?
  • Any alternative approaches or best practices for handling time limits in Google Apps Script when working with Google Drive?

Thank you very much for any insights or suggestions you might have. I appreciate your expertise!

Best regards,
Otto OntanedaScreenshot 2024-10-31 at 8.16.23 PM.png

Edward Friedman (Eddie)

unread,
Nov 3, 2024, 1:40:17 PMNov 3
to Google Apps Script Community
Take a look here. There is a tool specifically for getting a folder tree in deeply nested scenarios. 

Reply all
Reply to author
Forward
0 new messages