0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[GAS]フォルダ一覧の取得

Last updated at Posted at 2020-10-19

function getFolders() {
  
  rowIndex = 1; // The starting row of a range.
  colIndex = 1; // The starting row of a column.
  
  const sheetName = "シート1"; //入力したいシートを宣言
  
  const folder_id = "1*********************"; //フォルダIDを指定する
  
  const folders = DriveApp.getFolderById(folder_id).getFolders();
  
  let foldersArray = [];
  
  while(folders.hasNext()){
    const childFolder = folders.next();
    //console.log(childFolder.getName())
    //console.log("Name: "+ childFolder.getName()+" \nURL: https:\/\/drive.google.com\/drive\/u\/0\/folders\/"+childFolder.getId())
    foldersArray.push([childFolder.getName(), childFolder.getUrl()]);
  }
  
  const range = SpreadsheetApp.getActive().getSheetByName(sheetName).getRange(rowIndex, colIndex, foldersArray.length, foldersArray[0].length);
  range.setValues(foldersArray);
}

時間ができたら細かく説明します

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?