Skip to content

Instantly share code, notes, and snippets.

@shop-0761
Created November 16, 2017 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shop-0761/f2b3243315bf33c55dd1af400f650daa to your computer and use it in GitHub Desktop.
Save shop-0761/f2b3243315bf33c55dd1af400f650daa to your computer and use it in GitHub Desktop.
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