Last active
September 8, 2022 00:53
-
-
Save tecking/02f3b5ad2f8f46a78255c3cfdc5f2915 to your computer and use it in GitHub Desktop.
Google Jamboard を複製して URL 一覧を作成するだけの Google Apps Script (GAS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Google Jamboard を複製して URL 一覧を作成するだけの Google Apps Script (GAS) | |
* 2つの学級 A, B に、それぞれ10個の Jamboard を設ける例 | |
* Jamboard のファイル名と URL をペアにした一覧表をスプレッドシートで出力 | |
*/ | |
const folderId = 'TARGET_FOLDER_ID'; | |
const templateFileId = 'TEMPLATE_JAMBOARD_FILE_ID'; | |
const className = [ | |
'A', 'B' | |
]; | |
const group = [ | |
'①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩' | |
]; | |
var i, j; | |
function copyJamboard() { | |
const templateFile = DriveApp.getFileById(templateFileId); | |
let fileList = []; | |
for (i = 0; i < className.length; i++) { | |
for (j = 0; j < group.length; j++) { | |
let fileName = `${className[i]}クラス - グループ${group[j]}`; | |
let newFile = templateFile.makeCopy(fileName); | |
newFile.setSharing(DriveApp.Access.DOMAIN_WITH_LINK, DriveApp.Permission.EDIT); | |
fileList.push([fileName, newFile.getUrl()]); | |
} | |
} | |
return fileList; | |
} | |
function createSpreadsheet(fileList) { | |
const ssFile = SpreadsheetApp.create('Jamboardリンク先一覧'); | |
const sheet = ssFile.getActiveSheet(); | |
for (i = 0; i < fileList.length; i++) { | |
sheet.getRange(i+1, 1).setValue(fileList[i][0]); | |
sheet.getRange(i+1, 2).setValue(fileList[i][1]); | |
} | |
DriveApp.getFileById(ssFile.getId()).moveTo(DriveApp.getFolderById(folderId)); | |
return; | |
} | |
function main() { | |
let fileList = copyJamboard(); | |
createSpreadsheet(fileList); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment