LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Monday, August 15, 2022

Google Driveにあるファイルの説明を読み書きしたい


ここで言うGoogle Driveにあるファイルの説明とは

ファイルの詳細にある「説明を追加」項目です。
詳細の表示・非表示は右上の「i」アイコンで切り替えられます。



説明を追加する



コード.gs
function updateFileDescription() {
  const fileId = "FILE_ID;
  const text = "テキスト入力\n次の行";
  const file = DriveApp.getFileById(fileId);
  file.setDescription(text);
}



実行結果





説明を取得する



コード.gs
function getFileDescription() {
  const fileId = "FILE_ID";
  const file = DriveApp.getFileById(fileId);
  const description = file.getDescription();
  Logger.log(description);
}



実行結果



参考

getDescription() 

setDescription(description)

Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...