Blog
Main » 2011 March 25 » Unzipper9:22 PM Unzipper |
This program is to unzip a zipped file into a selected directory via command line. This script needs unzip.exe installed in your Windows directory. Anyway, you can download that here or by using the script I made. If you find bugs, please do tell me. By the way, this script only supports extracting files into a directory by overwriting the files or doing nothing to existing files with the same name in the extraction folder.
Code ; Thanks to Info-Zip's unzip.exe ; Visit their website at http://www.info-zip.org ; For more information about their product ; Thanks to JGR and Sean for the downloader #SingleInstance ignore #NoEnv Menu, SubMenu , Add, Download unzip.exe, DownloadUnzipEXE Menu, MainMenu, Add, Menu, :SubMenu Gui, Menu , MainMenu Gui, Font, , Courier New Gui, Add, Text, x6 y7 w360 h20 , AutoHotkey UnZipper Gui, Add, Text, x6 y37 w110 h20 , File to UnZip: Gui, Add, Text, x6 y57 w110 h20 , Extract to: Gui, Add, Edit, x116 y37 w180 h20 , ; File to Extract Gui, Add, Edit, x116 y57 w180 h20 , ; Extract to Gui, Add, Button, x296 y37 w70 h20 gButtonSelectFile, Browse Gui, Add, Button, x296 y57 w70 h20 gButtonSelectPath, Browse Gui, Add, CheckBox, x116 y77 w250 h20 , Overwrite Existing Files Gui, Add, Button, x6 y97 w360 h30 gButtonUnzipFile , UnZip Gui, Show,, AutoHtokey UnZipper return GuiClose: ExitApp DownloadUnzipEXE: ; Downloads unzip.exe sUrl = http://stahlworks.com/dev/unzip.exe ; Download source sFile = %A_WinDir%\unzip.exe ; Destination Progress, % "M W" . A_ScreenWidth//2, 0, 0 of 0 VarSetCapacity(vt, 4*11), nParam = 31132253353 Loop, Parse, nParam NumPut(RegisterCallback("DownloadProgress", "Fast", A_LoopField, A_Index-1), vt, 4*(A_Index-1)) DllCall("urlmon\URLDownloadToFileA", "Uint", 0, "str", sUrl, "str", sFile, "Uint", 0, "UintP", &vt) DownloadProgress(pthis, nProgress = 0, nProgressMax = 0, nStatusCode = 0, pStatusText = 0) { if A_EventInfo = 6 Progress, % p := 100 * nProgress//nProgressMax, %p%, % nProgress . " of " . nProgressMax return 0 } WinClose, ahk_class AutoHotkey2 return ButtonSelectFile: ; Selects a zipped file FileSelectFile, SelectedFile,,, Select a file to extract, *.zip* ; Changes the Edit1 box with the path of the selected file GuiControl, Text, Edit1, %SelectedFile% return ButtonSelectPath: ; Selects a fodler FileSelectFolder, SelectedFolder,,, Select a folder where to extract the selected file ; Changes the Edit2 box to the path of the selected folder GuiControl, Text, Edit2, %SelectedFolder% return ButtonUnzipFile: ; If unzip.exe is not existing in Windows directory IfNotExist, %A_WinDir%\unzip.exe MsgBox, 4, AutoHtokey UnZipper, Cannot find unzip.exe in your Windows directory. Do you want to download it now? IfMsgBox, Yes Gosub, DownloadUnzipEXE else return ; Gets the texts in the Edit boxes GuiControlGet, SelectedFile,, Edit1 if (SelectedFile = "") { ; If the text box has to value MsgBox, 32, AutoHtokey UnZipper, Please select a file. return } GuiControlGet, SelectedFolder,, Edit2 if (SelectedFolder = "") { ; If the text box has to value MsgBox, 32, AutoHtokey UnZipper, Please select a folder. return } ; Gets if the 'Overwrite Existing File' is checked GuiControlGet, Overwrite,, Button3 ; If the checkbox is checked if (Overwrite = 1) { ; This overwrites existing files without prompting RunWait, %ComSpec% /c unzip -o "%SelectedFile%" -d "%SelectedFolder%" }else{ ; This never overwrties existing files RunWait, %ComSpec% /c unzip -n "%SelectedFile%" -d "%SelectedFolder%" } MsgBox, 32, AutoHtokey UnZipper, Files unzipped. return Credits: |
|
Total comments: 0 | |