;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Total Commander DreamLair ;
; Script: Unpack Selected Archives with 7-Zip ;
; Script version: 1.0 (2018.09.14) ;
; Script author: LonerD ;
; Site: https://dreamlair.net ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Parameters: ;
; 1) %WL (required) ;
; 2) Path to archiver (required) ;
; ("%%commander_path%%\Plugins\arc\7-Zip\7zG.exe") ;
; 3) Unpack to subdir (1|0) ;
; 4) Unpack only supported extensions (1|0) ;
; 5) Mode (a|s|u - overwrite all|skip|rename) ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
#NoEnv
#NoTrayIcon
#SingleInstance ignore
if not ( WinExist("ahk_class TTOTAL_CMD") || WinActive("ahk_class TTOTAL_CMD") )
ExitApp
Filelist = %1%
7ZipPath = %2%
ToSubdir = %3%
Supported = %4%
Overwrite = %5%
if 0 < 5
Overwrite = u
if 0 < 4
Supported = 1
if 0 < 3
ToSubdir := 1
if 0 < 2
ExitApp
EnvGet, commander_path, commander_path
Transform, 7ZipPath, Deref, % 7ZipPath
7ZipPath := ExpandEnvVars (7ZipPath)
if Overwrite not in a,s,u
Overwrite:= s
if Supported not in 0,1
Supported:= 1
if ( Supported = "1" )
SupportedExt := "7z,7zip,7-zip,exe,bz2,bzip2,tbz2,tbz,gz,gzip,tgz,tar,wim,swm,esd,xz,txz,zip,zipx,jar,apk,xpi,odt,ods,docx,xlsx,epub,apm,ar,a,deb,lib,arj,cab,chm,chw,chi,chq,msi,msp,doc,xls,ppt,cpio,cramfs,dmg,ext,ext2,ext3,ext4,fat,hfs,hfsx,hxs,hxi,hxr,hxq,hxw,lit,ihex,iso,img,lha,lzh,lzma,mbr,mslz,mub,nsis,ntfs,rar,r00,rpm,ppmd,qcow,qcow2,qcow2c,squashfs,udf,scap,uefif,vdi,vhd,vmdk,xar,pkg,z,taz"
Loop, Read, % Filelist
{
TargetFile = %A_LoopReadLine%
SplitPath, TargetFile, FileName, FileDir, FileExt, FileNameNoExt
if not InStr(FileExist(TargetFile), "D")
{
if ( ToSubdir = "0" )
TargetPath := FileDir . "\"
else
TargetPath := FileDir . "\" . FileNameNoExt . "\"
While InStr(TargetPath, ".\")
TargetPath := StrReplace(TargetPath, ".\", "\")
if ( Supported = "0" )
RunWait, %7ZipPath% x -scsUTF-8 -ao%Overwrite% -o"%TargetPath%" -- "%TargetFile%"
else if FileExt in % SupportedExt
RunWait, %7ZipPath% x -scsUTF-8 -ao%Overwrite% -o"%TargetPath%" -- "%TargetFile%"
}
}
ExitApp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
ExpandEnvVars(ppath)
{
VarSetCapacity(Dest, 2000)
DllCall("ExpandEnvironmentStrings", Str, ppath, Str, Dest, Int, 1998)
Return, Dest
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; |