Example 3: Compress a directory that includes the root directory The Draft.zip file only contains Draftdoc.docxĪnd diagram2.vsd. Specifies the location for the Draft.zip file. TheĬompression level is Fastest to reduce processing time. The Path uses a comma-separated list to get files from different directories. $compress = "C:\Reference\Draft Doc.docx", "C:\Reference\Images\diagram2.vsd"Ĭompress-Archive path and file names are used because the LiteralPath parameter doesn't accept Structure in the archive file because the Path only specifies file names. This example compresses specific named files and creates a new archive file. Example 2: Compress files using a LiteralPath The Draft.zip file contains Draftdoc.docx and all the files with a The DestinationPath parameter specifies the locationįor the Draft.zip file. ![]() Path uses a comma-separated list to get files from different directories. $compress = "C:\Reference\Draftdoc.docx", "C:\Reference\Images\*.vsd"ĭestinationPath = "C:\Archives\Draft.zip"Ĭompress-Archive Path parameter accepts specific file names and file names with wildcards, *.vsd. There's no directory structure in theĪrchive file because the Path only specifies file names. ![]() Used to get all files with a particular file extension. This example compresses files from different directories and creates an archive file. ![]() Examples Example 1: Compress files to create an archive file For more information, seeĪbout_Splatting. Some examples use splatting to reduce the line length of the code samples. To ensure hidden files and folders are compressed into the archive, use the. On non-Windows machines, this includes files and folders with name that begins with The Compress-Archive cmdlet ignores hidden files and folders when creating or updating theĪrchive file. The maximum file size is 2 GB because there's a limitation of the underlying API. System.IO.Compression.ZipArchive to compress files. The Compress-Archive cmdlet uses the Microsoft. The compression algorithm specified by the CompressionLevel parameter. An archive file can be compressed by using An archive packages multiple files, with optional compression, intoĪ single zipped file for easier distribution and storage. The Compress-Archive cmdlet creates a compressed, or zipped, archive file from one or more Creates a compressed archive, or zipped file, from specified files and directories.
0 Comments
Leave a Reply. |