Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Кнопки для 7-Zip 
Author Message
LonerD



PostPosted: Fri Sep 14, 2018 15:16    Post subject: Reply with quote

AutoHotkey скрипт для распаковки выделенных файлов с помощью архиватора 7-Zip (всё в текущий каталог или же для каждого архива будет создаваться отдельный каталог с именем файла).
Предусмотрена проверка на наличие точки в конце каталога куда производится распаковка.
Можно пытаться распаковывать как все файлы (архиватор будет выводить стандартное окно ошибки если не может осилить распаковку), так и только файлов из списка поддерживаемых форматов (список взят из справки 7-Zip).

Ссылка на скрипт.

Примерный вариант параметров
%WL "%%commander_path%%\Plugins\arc\7-Zip\7zG.exe" 1 1 u
Unpack selected archives with 7-Zip

%WL "%%commander_path%%\Plugins\arc\7-Zip\7zG.exe" 0 1 u
Unpack selected archives with 7-Zip to current directory


Code:

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; 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
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;

_________________
Win11 x64 Eng | TC DreamLair eternal pre-α
View user's profile Send private message Visit poster's website ICQ Number


Powered by phpBB © 2001, 2005 phpBB Group