在我的脚本中,我试图创建一个文件夹,在所述文件夹中创建一个带有日期标记的文档,创建一个子文件夹,并将一些文档复制到该子文件夹中。创建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