I'm trying to write some Google Apps Script to extract a zip file which has 3 subfolders. Depending on the folder, I will then run through the various files and process them accordingly.
I cannot get Utilities.unzip to work when the zip file contains subfolders. I tested my code with a simple zip file and it worked as expected, so I'm guessing it is something I am missing or the .unzip simply does not work on subfolders.
Is there anyway to get this to work? Or can I extract the files via javascript and pass these to the apps script? I had a look at a couple of javascript libraries that do this but couldn't work out how to import these into my Google Web App.
UPDATE: Here is the code I have been using to test:
function ExtractSecurityZip() {
var iZIP =DriveApp.getFileById("1RAhI_mGQHay9boCQ9tt5T_0iqF6w5Eky").getBlob().setContentTypeFromExtension()
Utilities.unzip(iZIP)
return
}
I am not concerned about maintaining the folder structure in the zip file, I just need all the files.
Any help is greatly appreciated.
Dave
PS: If it helps, the zip file is an Oracle LCM Export, so I cannot remove the folder structure.
This will unzip all the the files to a destination directory
Here's what looping through blobs.getName() reveals:
The ones that end in '/' are directories the others are files. I messed around with trying to restore the directory structure but it's a bit more work than I thought. So you might want to add the Javascript Tag to your list of tags. My guess is that one of them have already figured it out.
With regard to the question asked by andrewjames: Can you run this on your zip file so that I can see what it looks like?