1, I want to count the files in a zip, and judge that only one fold or a file or some files in it.
In order to unzip through one shortcut to a new fold with the same name of the file, even if there is already a fold in it.
There are three conditions in the file:
A, Only one file
a, Unzip to the current fold
b, If the file exists, then rename it by the name add(1)
B, Only one fold
a, Unzip to the current fold directly
b, If the fold exists, the new fold name add(1)
C, Some files may be with fold(s)
a, Unzip to the new fold with the zip file name
b, If the fold exists, the new fold name add(1)
https://github.com/tterb/AutoHotkey-Scripts/blob/master/7zip.ahk
Code: Select all
^+y::
temp = %clipboard%
;KeyWait, LButton, D
;send {LButton}
sleep,100
Send, {Ctrl Down}c{Ctrl Up}
sleep,200
file = %clipboard% ;get file address
clipboard = %temp% ;restore clipboard
outdir := getdir(file)
runwait, "C:\Program Files\7-Zip\7z.exe" x "%file%" -o"%outdir%" -y,,hide ;Unzip to the same path and add a new fold
TrayTip, ,7zip has finished extracting "%file%", 1, 16
return
getdir(input)
{
SplitPath, input,,parentdir,,filenoext
final = %parentdir%\%filenoext%
return final
}
Code: Select all
q::
TempDir =D:\12
oShell := ComObjCreate("Shell.Application")
oDir := oShell.NameSpace(TempDir)
Loop %TempDir%\*.zip
{
oZip := oShell.NameSpace(A_LoopFileFullPath)
if !(oZip && oDir)
{
MsgBox 16, AutoHotkey,failed: unzip error.
Run %TempDir%
ExitApp
}
oDir.CopyHere(oZip.Items, 4)
}
oShell := oDir := oZip := ""
return