GAS googleドライブ内で今日更新されたファイルを抽出する
- 作成日 2023.01.04
- Google Apps Script
- Google Apps Script
GAS(Google Apps Script)で、googleドライブ内で今日更新されたファイルを抽出する手順を記述してます。「searchFiles」に現在日付を条件にすることで可能です。
環境
- OS windows11 home
- ブラウザ chrome 108.0.5359.125
今日更新されたファイルを抽出
今日更新されたファイルを抽出するには、「searchFiles」を使用します。
// 本日の日付を yyyy-mm-dd で取得して条件に適応
const query = `modifiedDate >= '${Utilities.formatDate(new Date(), "JST", "yyyy-MM-dd")}'`;
const files = DriveApp.searchFiles(query);
実際に、取得するコードは以下となります。
function myFunction() {
const query = `modifiedDate >= '${Utilities.formatDate(new Date(), "JST", "yyyy-MM-dd")}'`;
const files = DriveApp.searchFiles(query);
while (files.hasNext()) {
const file = files.next();
Logger.log(`ファイル名 : ${file.getName()} 更新日時 : ${file.getLastUpdated()}`);
}
}
実行結果
-
前の記事
Rust unix timeを取得する 2023.01.04
-
次の記事
Oracle Database 指定したカラムを別の名前として抽出する 2023.01.04
コメントを書く