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

后端 未结 5 900
小鲜肉
小鲜肉 2020-12-21 09:46

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

5条回答
  •  不思量自难忘°
    2020-12-21 10:29

    For a Spreadsheet I found this to work:

    thisFileId = SpreadsheetApp.getActive().getId();
    var thisFile = DriveApp.getFileById(thisFileId);
    var parentFolder = thisFile.getParents()[0].getName();
    

提交回复
热议问题