Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I locate the path of the folder in which the current script file is located?

How do I locate the path of the current folder? I just want to be able to get the path of the folder so that I can manipulate the files in the folder without typing the path into the scripts.

like image 379
user2054013 Avatar asked Dec 04 '22 00:12

user2054013


1 Answers

For a Spreadsheet I found this to work:

thisFileId = SpreadsheetApp.getActive().getId();
var thisFile = DriveApp.getFileById(thisFileId);
var parentFolder = thisFile.getParents()[0].getName();
like image 159
hansvb Avatar answered Jun 20 '23 09:06

hansvb