Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GASでzipをつくるやつ
//フォルダの中身をzipにする関数
function makeZip(fileName, folderId){
var folder = DriveApp.getFolderById(folderId);
var fileList = folder.getFiles();
var archive = "";
var blobs = new Array();
while(fileList.hasNext()){
var file = fileList.next();
if(file.getName() == fileName + ".zip"){
folder.removeFile(file);
continue;
}
blobs.push(file.getBlob());
}
var zip = Utilities.zip(blobs, fileName + ".zip");
var id = folder.createFile(zip).getId();
Logger.log("zipurl: " + "https://drive.google.com/uc?id=" + id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.