用JavaScript操作WinRar_javascript技巧

來源:互聯網
上載者:User
要先儲存到本地在運行
<label>Select a file <input type="file" name="sFile" id="sFile" /> </label> <label> <input type="button" name="Button" value="Button" onclick="runRar()" /> <textarea row="5" col="50" id="showCmd"></textarea> </label> <script language="javascript" type="text/javascript"> function runRar(){ var winRar=new ActiveXObject("WScript.Shell"); var fName=document.getElementById("sFile").value fName=fName.replace(/\\/,"\\\\"); rName=fName.replace(/\./,"_"); alert(fName); var cmd="winrar a "+ rName + ".rar " + fName + " -r" ; winRar.run(cmd,1,true); } </script>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]


以下是相關的命令:

任務描述 
 Winzip
 Winrar

壓縮目錄test及其子目錄的檔案內容 
 Wzzip test.zip test -r –P
 WINRAR A test.rar test -r

刪除壓縮包中的*.txt檔案 
 Wzzip test.zip *.txt –d
 WinRAR d test.rar *.txt

重新整理壓縮包中的檔案,即添加已經存在於壓縮包中但更新的檔案 
 Wzzip test.zip test –f
 Winrar f test.rar test

更新壓縮包中的檔案,即添加已經存在於壓縮包中但更新的檔案以及新檔案 
 Wzzip test.zip test –u
 Winrar u test.rar test

移動檔案到壓縮包,即添加檔案到壓縮包後再刪除被壓縮的檔案 
 Wzzip test.zip -r -P –m
 Winrar m test.rar test -r

添加全部 *.exe 檔案到壓縮檔,但排除有 a或b 開頭名稱的檔案 
 Wzzip test *.exe -xf*.* -xb*.*
 WinRAR a test *.exe -xf*.* -xb*.*

加密碼進行壓縮 
 Wzzip test.zip test -s123。注意密碼是大小寫敏感的。(-s和密碼之間沒有空格) 
 WINRAR A test.rar test -p123 -r。注意密碼是大小寫敏感的。(-p和密碼之間沒有空格) 

按名字排序、以簡要方式列表顯示壓縮包檔案 
 Wzzip test.zip –vbn
 Rar l test.rar

鎖定壓縮包,即防止未來對壓縮包的任何修改 
 無對應命令 
 Winrar k test.rar

建立360kb大小的分卷壓縮包 
 無對應命令 
 Winrar a -v360 test

帶子目錄資訊解壓縮檔案 
 Wzunzip test –d
 Winrar x test -r

不帶子目錄資訊解壓縮檔案 
 Wzunzip test
 Winrar e test

解壓縮檔案到指定目錄,如果目錄不存在,自動建立 
 Wzunzip test newfolder\
 Winrar x test newfolder\

解壓縮檔案並確認覆蓋檔案 
 Wzunzip test –y
 Winrar x test -y 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.