How to Zip or Unzip Files Using the Command Prompt and Windows PowerShell
Zipping and unzipping files is a task that most computer users need to do at some point in time. While there are a lot of tools available for zipping and unzipping files, the command prompt and Windows PowerShell also offer this functionality. Here is a step-by-step guide on how to zip or unzip files using the command prompt and Windows PowerShell.
Zipping Files Using Command Prompt
- Open the command prompt. You can do this by pressing the Windows key + R on your keyboard and then typing cmd in the Run dialog box.
- Navigate to the folder that contains the files you want to zip. You can use the cd command to move to different directories.
- Type the following command to zip the files:
“`command
zip -r filename.zip foldername
“`
Replace filename.zip with the name you want to give to the zipped file and foldername with the name of the folder you want to zip. The -r option is used to include all subfolders in the zipped file.
- Press the Enter key to execute the command. The zip file will be created in the same folder where the original files were located.
Unzipping Files Using Command Prompt
- Open the command prompt.
- Navigate to the folder that contains the zipped file.
- Type the following command to unzip the file:
“`command
unzip filename.zip
“`
Replace filename.zip with the name of the zipped file.
- Press the Enter key to execute the command. The files will be extracted to the same folder where the zipped file was located.
Zipping Files Using Windows PowerShell
- Open Windows PowerShell. You can do this by pressing the Windows key + R on your keyboard and then typing powershell in the Run dialog box.
- Navigate to the folder that contains the files you want to zip.
- Type the following command to zip the files:
“`powershell
Compress-Archive -Path * -DestinationPath filename.zip
“`
Replace filename.zip with the name you want to give to the zipped file.
- Press the Enter key to execute the command. The zip file will be created in the same folder where the original files were located.
Unzipping Files Using Windows PowerShell
- Open Windows PowerShell.
- Navigate to the folder that contains the zipped file.
- Type the following command to unzip the file:
“`powershell
Expand-Archive -Path filename.zip -DestinationPath .
“`
Replace filename.zip with the name of the zipped file.
- Press the Enter key to execute the command. The files will be extracted to the same folder where the zipped file was located.