Unzipping Files

Unzipping files in Python

import zipfile
with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref:
zip_ref.extractall(directory_to_extract_to)

That's pretty much it!

Unzipping multiple file without loosing the original creation date

Actually opening multiple zip files manually keeps the dates, at least on macOS.
Search for the files you need to unzip, select -> open.

Unzipping files in REACT and then rezipping it again

You can use JSZIP

Example:

const zip = new JSZip();
zip.loadAsync(<YOUR .ZIP FILE>).then(<YOUR FILES IN AN ARRAY>)

unzipping the file using cypress

So, I tried all your code you gave above, and it worked perfectly.

The only thing I can think if is the contents of the zip is the problem. In my test I made a simple zip with two text files 1.txt and 2.txt, then running the test, found them in the folder /cypress/downloads/unzip/910-00001.1-20220419-1843.

I suggest you do the same with a dummy zip, if the code works then look at the contents of 910-00001.1-20220419-1843.zip.

Google Apps Script Unzipping Files - Issues

As what Rodrigo mentioned in the comments, you need to loop it on all the files. unZippedfile.length is the number of files in the zip file. Use a loop around the createFile method.

Code:

// loop to all zip files
while (ZIPFiles.hasNext()){
var fileBlob = ZIPFiles.next().getBlob();
var unZippedfile = Utilities.unzip(fileBlob);
// loop to all items inside the current zip file
for (i=0; i<unZippedfile.length; i++) {
var newDriveFile = DestinationFolder.createFile(unZippedfile[i]);
}
}

Output:

output

Note:

  • Sample output above show the unzipped files on the same directory as I instantiated both source and destination with the same directory ID.


Related Topics



Leave a reply



Submit