![]() ![]() ![]() Compress-Archive -Path C:\path\to\files -Update -DestinationPath C:\path\to\archive.zipĪnd this concludes the process of the various scenarios that you can zip files using PowerShell in Windows 10. This lets you replace older file versions in the archive with newer ones that have the same names, and add files that have been created in the root directory. Now, it’s imperative to point out that even after the archive is complete, you can update an existing zipped file with the use of the -Update parameter with the correct syntax provided below. Compress-Archive -Path C:\path\to\file\*.* -DestinationPath C:\path\to\archive.zip ![]() With this method too, subdirectories and the files of the root folder aren’t included in the archive. Lastly, if you want an archive that only compresses files in the root directory and all its subdirectories, you will use the star-dot-star (*.*) wildcard to zip the files with the syntax below. Bear in mind that subdirectories and the files of the root folder aren’t included in the archive with this method.Ĭompress-Archive -Path C:\path\to\file\*.docx -DestinationPath C:\path\to\archive.zip PowerShell will archive the files specified without touching the others explicitly. jpg, etc.) but only want to compress all of one type, you can use the syntax below. Now, in the case whereby you have a folder with a bunch of different file types (.docx. Compress-Archive -Path C:\path\to\file\* -DestinationPath C:\path\to\archive.zip By adding an asterisk (*) to the end of the file path, PowerShell will only grab what’s inside of the root directory. However, if you want to exclude the root folder from the Zip file, you can use a wildcard to omit it from the archive. Now, from both examples given above, you have seen how to include the root directory and all of its files and subdirectories when creating an archive file. To use a wildcard with Compress-Archive, you must use the -Path parameter instead, as -LiteralPath does not accept them. When you use the character, you can exclude the root directory, compress only files in a directory, or choose all files of a specific type. The Compress-Archive cmdlet lets you use a wildcard character (*) to expand the functionality even further. PowerShell takes everything inside of the root directory and compresses it, subfolders, and all. This command puts the path to a directory with multiple files and folders in it without specifying individual files. It should look like as shown in the image below. Also, bear in mind that quotations around the path are only necessary when the file path contains a space.Īlternatively, to zip the entire contents of a folder and all of its subfolders, you can use the same syntax as above, replacing and placeholder with the path to the files you want to compress and the name and folder you want it to go, respectively. Note: When you provide the destination path, be sure to give the archive file a name or PowerShell will save it as “.zip” where you specify. Compress-Archive -LiteralPath -DestinationPath Next, type in the syntax below, replacing and placeholder with the path to the files you want to compress and the name and folder you want it to go, respectively. Press Windows key X to open Power User Menu and then press I on the keyboard to launch PowerShell. It takes the path to any files you want to compress-multiple files are separated with a comma-and archives them in the destination you specify. You begin by compressing some files into a ZIP file archive using the Compress-Archive cmdlet. In this post, we will show you how to zip and unzip files using the PowerShell utility in Windows 11/10. This process saves disk space, encrypts data, and makes it easy to share files with others. Essentially, the ZIP file format reduces the size of files by compressing them into a single file. ![]()
0 Comments
Leave a Reply. |