|
/** |
|
* Google Meet録画・議事録を共有ドライブに移動するスクリプト |
|
* 特定のタイトルで始まるファイルのみ対象 |
|
|
|
* 使い方: |
|
* Google Apps Scriptで新しいプロジェクトを作成 |
|
* 下記コードを貼り付け |
|
|
|
* CONFIGの2箇所を設定: |
|
* TARGET_PREFIX: 対象の会議タイトル(例:'週次定例'、'〇〇プロジェクト'など) |
|
* DEST_FOLDER_ID: 共有ドライブのフォルダIDをURLから取得 |
|
|
|
* createTriggerを一度実行してトリガー設定 |
|
* 初回はDrive APIの権限承認を求められるので許可 |
|
*/ |
|
|
|
|
|
// ===== 設定 ===== |
|
const CONFIG = { |
|
// 移動対象のタイトルプレフィックス(この文字列で始まるファイルのみ移動) |
|
TARGET_PREFIX: 'ここに対象タイトルを設定', |
|
|
|
// 共有ドライブの移動先フォルダID |
|
DEST_FOLDER_ID: 'ここに移動先フォルダIDを設定' |
|
}; |
|
|
|
function moveMeetRecordings() { |
|
const meetFolder = getMeetRecordingsFolder(); |
|
const destFolder = DriveApp.getFolderById(CONFIG.DEST_FOLDER_ID); |
|
|
|
const files = meetFolder.getFiles(); |
|
let movedCount = 0; |
|
|
|
while (files.hasNext()) { |
|
const file = files.next(); |
|
const name = file.getName(); |
|
const mimeType = file.getMimeType(); |
|
|
|
// 対象タイトルで始まるかチェック |
|
if (!name.startsWith(CONFIG.TARGET_PREFIX)) { |
|
continue; |
|
} |
|
|
|
// 動画または議事録のみ対象 |
|
const isVideo = mimeType === 'video/mp4'; |
|
const isDoc = mimeType === 'application/vnd.google-apps.document'; |
|
|
|
if (isVideo || isDoc) { |
|
file.moveTo(destFolder); |
|
const type = isVideo ? '録画' : '議事録'; |
|
console.log(`${type}を移動: ${name}`); |
|
movedCount++; |
|
} |
|
} |
|
|
|
console.log(`完了: ${movedCount}件移動しました`); |
|
} |
|
|
|
function getMeetRecordingsFolder() { |
|
const folders = DriveApp.getFoldersByName('Meet Recordings'); |
|
if (folders.hasNext()) { |
|
return folders.next(); |
|
} |
|
throw new Error('Meet Recordingsフォルダが見つかりません'); |
|
} |
|
|
|
// 定期実行トリガーを設定(初回のみ実行) |
|
function createTrigger() { |
|
// 既存のトリガーを削除 |
|
ScriptApp.getProjectTriggers().forEach(t => ScriptApp.deleteTrigger(t)); |
|
|
|
// 5分ごとに実行 |
|
ScriptApp.newTrigger('moveMeetRecordings') |
|
.timeBased() |
|
.everyMinutes(5) |
|
.create(); |
|
|
|
console.log('トリガーを設定しました(5分ごとに実行)'); |
|
} |