Skip to content

Instantly share code, notes, and snippets.

@asika32764
Last active October 9, 2022 09:29
Show Gist options
  • Save asika32764/d178fb5a5365f5f2d3fa to your computer and use it in GitHub Desktop.
Save asika32764/d178fb5a5365f5f2d3fa to your computer and use it in GitHub Desktop.
在 Windows 中用 WinRAR.exe 實現 zip & unzip 指令

在 Windows 中用 WinRAR.exe 實現 zip & unzip 指令

安裝方式

首先你需要安裝 WinRAR,然後在任何你想放指令的位置(例如 C:\bin),將環境變數指向到這邊來。

接著下載這兩個 bat 檔,放在你環境變數指向的位置即可。

使用方式

ZIP

打開 cmd 或 PowerShell,輸入以下指令

$ zip <Zip file> <Target Folder>

例如

$ zip C:\www\myfile.zip C:\www\myfolder

UNZIP

輸入以下指令

$ unzip <Zip file> <Target Folder>

例如

$ unzip C:\www\myfile.zip C:\www\myfolder

參考資源

WinRAR Manual http://acritum.com/software/manuals/winrar/

Using the WinRAR Command-line tools in Windows http://comptb.cects.com/using-the-winrar-command-line-tools-in-windows/

use winrar command line to create zip archives http://stackoverflow.com/questions/3828765/use-winrar-command-line-to-create-zip-archives

@ECHO OFF
"C:\Program Files\WinRAR\WinRAR.exe" x %1 *.* %2\
@ECHO OFF
"C:\Program Files\WinRAR\WinRAR.exe" u -afzip -ep1 %*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment