在我的腳本中,我試圖創建一個文件夾,在所述文件夾中創建一個帶有日期標記的文檔,創建一個子文件夾,並將一些文檔複製到該子文件夾中。創建zip文件只包含pdf
這一切都很好。當我嘗試通過以下任一方法壓縮父文件夾時:Creating a zip file inside google drive with apps script - 它創建一個zip文件,其中帶有與日期標記文檔具有相同名稱的唯一PDF文件。壓縮的PDF是空白的,子文件夾不在那裏。
任何有關爲什麼會發生這種情況的見解會很好。
var folder = DocsList.createFolder(folderTitle);
var subFolder = folder.createFolder('Attachments');
subfolder.createFile(attachments[]); //In a loop that creates a file from every
//attachment from messages in thread
var doc = DocumentApp.create(docTitle); //Google Doc
var docLocation = DocsList.getFileById(doc.getId());
docLocation.addToFolder(folder);
docLocation.removeFromFolder(DocsList.getRootFolder());
//Everything works fine, I can view file and subfolder, and subfolder's documents
//This is where the problem is:
var zippedFolder = DocsList.getFolder(folder.getName());
zippedFolder.createFile(Utilities.zip(zippedFolder.getFiles(), 'newFiles.zip'));
//this results in a zipped folder containing one blank pdf that has the same title as doc
你可以發佈腳本嗎? – UpHelix 2013-02-08 16:02:34