스프레드 시트의 데이터에서 Google 드라이브의 새 폴더 만들기를 자동화하려고합니다. 스프레드 시트는 양식에서 정보를 가져옵니다. 스크립트를 사용하여 새 폴더를 만드는 방법을 알아 냈지만 다음과 같은 질문이 있습니다.새 폴더를 만들고 새 폴더에 새 이름으로 Google 시트 복사
- 스크립트를 실행할 때마다 중복 폴더가 생성되는 것을 방지하려면 어떻게합니까? 예를 들어, '1808'이라는 폴더가 이미 생성 된 경우 스크립트에서 '1808 (1)'을 만들지 않으려합니다.
다른 위치에서 스프레드 시트를 복사하고 새 폴더에 삽입하려고합니다. 만들고있어. 새 파일 이름은 동일한 스프레드 시트의 정보로 작성됩니다.
function makeFolders(){ //Get array of folder names (fixed & variable) var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getActiveSheet(); var bottomRow = sheet.getMaxRows()-2; var folderNames = sheet.getRange(2, 12, bottomRow, 1).getValues(); //If fixed name cell is blank it throws up an alert and stops if (folderNames === "") { SpreadsheetApp.getUi().alert('Cell A3 is blank.'); } //If folder ID cell is blank it throws up an alert and stops var folderUrl = sheet.getRange(3,14).getValue(); if (folderUrl === "") { SpreadsheetApp.getUi().alert('Cell C3 is blank.'); } //If fixed name cell and file URL aren't empty, run the program if (folderNames !== "" && folderUrl !== "") { //Get ID from folder URL var folderId = folderUrl.match(/[-\w]{25,}/); //Get master folder var getRootFolderId = DriveApp.getFolderById(folderId); //Copy master n times and rename each copy with the new name //stops when it comes to a blank cell for (n=0;n<bottomRow;n++){ if(folderNames[n] == ""){break;} var newFolder = getRootFolderId.createFolder(folderNames[n]); } ss.toast("Your folders have been made! :)","Finished",3); } }**strong text**
스크립트에 대해 더 자세히 배우면서 onopen을 사용하는 대신 onedit을 사용하여 폴더를 만들 수 있습니다. –