Using Google App Script Unzip a file from Google Drive

Viewed 7431

I need a script that will unzip files that I have uploaded to my google drive and place the contents of the zip file back in my google drive.

I am having trouble with it. It runs with no errors, but the file it uploads is empty. I am very new to Google App Script, so any help would be greatly appreciated. Thanks.

function unZipIt() {
  var theFolder = DriveApp.getFolderById('0B9jgHw-WmzvfRS1ZZEhTc3Byak0')
  var theFile = theFolder.getFilesByName('Dock to Stock Weekly_Dock to Stock AMP.zip')
  var fileBlob = theFile.next().getBlob()

  fileBlob.setContentType("application/zip")

  var unZippedfile = Utilities.unzip(fileBlob)
  var fileId = SpreadsheetApp.create(unZippedfile).getId();  
  var file = DriveApp.getFileById(fileId);
  DriveApp.addFile(file)
  }
1 Answers
Related