79452685

Date: 2025-02-19 20:24:34
Score: 1
Natty:
Report link

When the script is not bound to the spreadsheet you can still get IDs and use the IDs to make the move:

function moveSpreadsheet(spreadSheetID, newFolderID) {

  //Get the spreadsheet file
  let file = DriveApp.getFileById(spreadSheetID);

  //Get the target folder
  let newFolder = DriveApp.getFolderById(newFolderID);

  //Move the file to the new folder
  file.moveTo(newFolder);
}

To use this function you would need to already have the IDs. You can get the IDs by copying from the URLs as mentioned above. Spreadsheet IDs appear after "d/", and Folder IDs come at the end of the URL. If you already have the spreadsheet object, e.g. you programmatically created a new one, you can get its ID using the spreadsheet.getID() method.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Starts with a question (0.5): When the
  • Low reputation (1):
Posted by: life12