How can you zip or unzip from the script using ONLY Windows’ built-in capabilities?

To expand upon Steven Penny’s PowerShell solution, you can incorporate it into a batch file by calling powershell.exe like this: powershell.exe -nologo -noprofile -command “& { Add-Type -A ‘System.IO.Compression.FileSystem’; [IO.Compression.ZipFile]::ExtractToDirectory(‘foo.zip’, ‘bar’); }” As Ivan Shilo said, this won’t work with PowerShell 2, it requires PowerShell 3 or greater and .NET Framework 4.

How to create an encrypted ZIP file?

I created a simple library to create a password encrypted zip file in python. – here import pyminizip compression_level = 5 # 1-9 pyminizip.compress(“src.txt”, “dst.zip”, “password”, compression_level) The library requires zlib. I have checked that the file can be extracted in WINDOWS/MAC.

How to create full compressed tar file using Python?

To build a .tar.gz (aka .tgz) for an entire directory tree: import tarfile import os.path def make_tarfile(output_filename, source_dir): with tarfile.open(output_filename, “w:gz”) as tar: tar.add(source_dir, arcname=os.path.basename(source_dir)) This will create a gzipped tar archive containing a single top-level folder with the same name and contents as source_dir.

Creating a ZIP archive in memory using System.IO.Compression

Thanks to ZipArchive creates invalid ZIP file, I got: using (var memoryStream = new MemoryStream()) { using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) { var demoFile = archive.CreateEntry(“foo.txt”); using (var entryStream = demoFile.Open()) using (var streamWriter = new StreamWriter(entryStream)) { streamWriter.Write(“Bar!”); } } using (var fileStream = new FileStream(@”C:\Temp\test.zip”, FileMode.Create)) { memoryStream.Seek(0, SeekOrigin.Begin); memoryStream.CopyTo(fileStream); … Read more

How can I Zip and Unzip a string using GZIPOutputStream that is compatible with .Net?

The GZIP methods: public static byte[] compress(String string) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(string.length()); GZIPOutputStream gos = new GZIPOutputStream(os); gos.write(string.getBytes()); gos.close(); byte[] compressed = os.toByteArray(); os.close(); return compressed; } public static String decompress(byte[] compressed) throws IOException { final int BUFFER_SIZE = 32; ByteArrayInputStream is = new ByteArrayInputStream(compressed); GZIPInputStream gis = new GZIPInputStream(is, BUFFER_SIZE); … Read more

What is a good Java library to zip/unzip files? [closed]

I know its late and there are lots of answers but this zip4j is one of the best libraries for zipping I have used. Its simple (no boiler code) and can easily handle password protected files. import net.lingala.zip4j.exception.ZipException; import net.lingala.zip4j.core.ZipFile; public static void unzip(){ String source = “some/compressed/file.zip”; String destination = “some/destination/folder”; String password = … Read more