Created
November 16, 2017 01:03
-
-
Save shop-0761/f2b3243315bf33c55dd1af400f650daa to your computer and use it in GitHub Desktop.
GASでzipをつくるやつ
This file contains 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
//フォルダの中身を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