Extracting a Zip file to a folder via CTB

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Extracting a Zip file to a folder via CTB

Post by aurumdigitus »

Have been very pleased since Zips were incorporated natively into XY.

An operation that occurs with great frequency here is to extract a Zip file's contents to a folder with that name. Now Command #280 "Extract here" is provided. However, that just dumps the files into the same folder.

Can a script be written that can be placed into a CTB that will take the selected Zip, create a folder with the same name and then put the extracted files in there?

Stef123

Re: Extracting a Zip file to a folder via CTB

Post by Stef123 »

aurumdigitus wrote:Have been very pleased since Zips were incorporated natively into XY.
Am I missing something? Doesn't work here. Neither on portable nor on install? :veryconfused:

aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Re: Extracting a Zip file to a folder via CTB

Post by aurumdigitus »

Maybe wrong nomenclature?

Try this: Right click a file with Zip extension, slide down for lines to zip, the menu opens.
Attachments
Zip menu.jpg
Zip menu.jpg (89.08 KiB) Viewed 3224 times

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Extracting a Zip file to a folder via CTB

Post by klownboy »

You may want to give highend's very nice "Extractor" a try. It will unzip the current file into a new folder with the name of the zip file. It's a button on my toolbar. http://www.xyplorer.com/xyfc/viewtopic. ... lit=autoit
There's an option to delete the file after extraction or keep it as well. It uses AHK but he has provided a compiled version and it will utilize the extractor of your choice.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Stef123

Re: Extracting a Zip file to a folder via CTB

Post by Stef123 »

aurumdigitus wrote:Right click a file with Zip extension, slide down for lines to zip, the menu opens.
Throws an error - which does not surprise me since I am on XP right now, but even my Win7 systems override the (really bad) Win zippers with tools that XY does not recognize.

I guess we have a very different interpretation of what you call "incorporated natively into XY" :cry:
klownboy wrote:You may want to give highend's very nice "Extractor" a try.
I did. Definitely an improvement. But still a far cry from the native support in other managers (my main reason for still using them).

aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Re: Extracting a Zip file to a folder via CTB

Post by aurumdigitus »

I guess we have a very different interpretation of what you call "incorporated natively into XY" :cry:
Must be that Zipping like beauty is in the eye of the beholder. Thus far - except for the query that initiated the thread - XY has been able to handle all my compression/decompression needs.

Stef123

Re: Extracting a Zip file to a folder via CTB

Post by Stef123 »

aurumdigitus wrote:XY has been able to handle all my compression/decompression needs.
Again - it's 3rd party that handles it. I didn't mean to question your taste :wink: , you made me question my workflow - if maybe I had overlooked something. :?:

Zipping is a function in my eyes. You'll drop your "beauty" the very instant XY tempts you with native support in list view. Bet on it. It's all about efficiency and comfort - not about loyalty to an old way of doing things.

Until then, I think highend's script will do exactly what you asked for.

aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Re: Extracting a Zip file to a folder via CTB

Post by aurumdigitus »

Again - it's 3rd party that handles it. I didn't mean to question your taste :wink:
Coding and scripting are largely outside my sphere of cognition. What XY is doing with Zips appears to be transparent - however Don pulls it off.

Anyway, as no one has come forward with a custom XYS will examine highend's Extractor as has been suggested.

mkolaski
Posts: 33
Joined: 16 Jul 2013 20:16
Location: UK

Re: Extracting a Zip file to a folder via CTB

Post by mkolaski »

No idea where I found this, but I've got the following set up for handling zip files:

Code: Select all

"_Initialize";
   perm $p_zip = "C:\Program Files\7-Zip\7zG.exe";
   perm $p_Zip = "C:\Program Files\7-Zip\7zFM.exe";
"just a message on winmount" msg "will NOT work on Winmount scripted created 7z files. <br> 7z created in the GUI will work. "
"&Open <curname> : open"
    openwith "$p_Zip";
-
"&List all this folder "
      selfilter "*.rar ; *.7z ; *.cab ; *.gz ; *.zip";
       $SelectedItems = get("SelectedItemsNames", "|");
   foreach($Item, $SelectedItems, "|") {
       rename s, " /";
        }
      wait 500;
      selfilter "*.rar ; *.7z ; *.cab ; *.gz ; *.zip";
       $SelectedItems = get("SelectedItemsNames", "|");
        foreach($Item, $SelectedItems, "|") {
         Run("cmd /c $p_zip l $Item >> <curfolder>.txt");
         wait 500;
          }
"List  <curname> single"
         rename s, " /";
        Run("cmd /c $p_zip l <curitem> > <curitem>.txt");
-
"7-Zip and move. (<curbase>.&7z and move) : 7z"
    focus;
    #113;
    focus;
    $curbase= <clipboard>;
    $l = strlen ($curbase);
    $p = strpos ($curbase, <crlf>);
   $curbase = regexreplace ($curbase, "^-1$", "$l");
    if ($p = "-1") { $p = $l ; }
    $curbase = substr ($curbase, 0, $p);
    $curbase = replace ($curbase," ","_");
   set $curbase, "$curbase.7z";
//Compress file with .zip. Name= base of file.
   $a =  get("path", i);
   openwith """$p_zip"" a -t7z $a\$curbase";
-
"Convert into <curbase>.&zip : zip"
  focus;
    #113;
    focus;
    $curbase= <clipboard>;
    $l = strlen ($curbase);
    $p = strpos ($curbase, <crlf>);
   $curbase = regexreplace ($curbase, "^-1$", "$l");
    if ($p = "-1") { $p = $l ; }
    $curbase = substr ($curbase, 0, $p);
    $curbase = replace ($curbase," ","_");
   set $curbase, "$curbase.zip";
//Compress file with .zip. Name= base of file.
 openwith """$p_zip"" a -tzip $curbase" ;
"Convert into <curbase>.&7z : 7z"
 focus;
    #113;
    focus;
    $curbase= <clipboard>;
    $l = strlen ($curbase);
    $p = strpos ($curbase, <crlf>);
   $curbase = regexreplace ($curbase, "^-1$", "$l");
    if ($p = "-1") { $p = $l ; }
    $curbase = substr ($curbase, 0, $p);
    $curbase = replace ($curbase," ","_");
   set $curbase, "$curbase.7z";
//Compress file with .zip. Name= base of file.
 openwith """$p_zip"" a -t7z $curbase"
-
"&Extract contents of <curname> here : ext"
   //Extract content to folder Name= base of zip. aot= If files exist, autonumber new files.
 openwith """$p_zip"" x -aot"
"&Extract contents of <curname> to folder <curbase> : extf"
    openwith """$p_zip"" x -y -o* -aot <items>"
"&Extract contents of <curname> to other pane w renumber existing : extfop"
         $a =  get("path", i);
   openwith """$p_zip"" x -y -o$a -aot <items>" ;
"&Extract contents of <curname> to other pane  : extfopr"
         $a =  get("path", i);
   openwith """$p_zip"" x -y -o$a  <items>" ;
"&Extract contents of <curname> to <curbase> other pane  : extfopra"
         $a =  get("path", i);
   openwith """$p_zip"" x -y -o$a\<curbase>\  <items>" ;
"&Extract contents of <curname> to other pane w renumber archive file : extfopr"
         $a =  get("path", i);
   openwith """$p_zip"" x -y -o$a -aou <items>" ;
"&Extract contents of <curname> to <curbase> other pane w renumber archive file : extfopra"
         $a =  get("path", i);
   openwith """$p_zip"" x -y -o$a\<curbase>\ -aou <items>" ;
-
"Convert into <curbase>.zi&p (password protection) : pzip"
  focus;
    #113;
    focus;
    $curbase= <clipboard>;
    $l = strlen ($curbase);
    $p = strpos ($curbase, <crlf>);
   $curbase = regexreplace ($curbase, "^-1$", "$l");
    if ($p = "-1") { $p = $l ; }
    $curbase = substr ($curbase, 0, $p);
    $curbase = replace ($curbase," ","_");
   set $curbase, "$curbase.zip";
 $i = input  (Input password for zipfile, password);
//Compress with .zip and password protect archive.
 openwith """$p_zip"" a -tzip $curbase -p$i"
"Convert into <curbase>.7z (password protection) : p7z"
    focus;
    #113;
    focus;
    $curbase= <clipboard>;
    $l = strlen ($curbase);
    $p = strpos ($curbase, <crlf>);
   $curbase = regexreplace ($curbase, "^-1$", "$l");
    if ($p = "-1") { $p = $l ; }
    $curbase = substr ($curbase, 0, $p);
    $curbase = replace ($curbase," ","_");
   set $curbase, "$curbase.7z";
 $i = input  (Input password for zipfile, password);
//Compress with 7z and password protect and encrypt archive headers.
 openwith """$p_zip"" a -t7z $curbase -p$i -mhe"
"?Set Password to <curname> : zp"
   global ($p_zip);
 set $file, <curbase>;
 openwith """$p_zip"" e -aou";
 msg "wait until extract",1;
 focus;
 filter $file*;
 delete 0,0;
 sortby created, d;
 sel 1;
 sub pzip;
 filter
"?Set Password to <curname> : z7"
   global ($p_zip);
 set $file, <curbase>;
 openwith """$p_zip"" e -aou";
 msg "wait until extract",1;
 focus;
 filter $file*;
 delete 0,0;
 sortby created, d;
 sel 1;
 sub p7z;
 filter
-
"Edit script : edit"
            $ScriptFile = self  ("file");
       run "$p_note" $ScriptFile,w;
-
"Cancel"
"_Terminate";
             unset $p_zip;
             unset $p_Zip;

EDIT: Added screenshot
03-07-2014 13-40-39.png
03-07-2014 13-40-39.png (109.18 KiB) Viewed 3142 times

HTH

Cheers,
Michael
Last edited by mkolaski on 03 Jul 2014 17:17, edited 1 time in total.

Stef123

Re: Extracting a Zip file to a folder via CTB

Post by Stef123 »

aurumdigitus wrote: Anyway, as no one has come forward with a custom XYS ...
:?: :?: :?: Your request: "...a CTB that will take the selected Zip, create a folder with the same name and then put the extracted files in there?"
klownboy's answer (about Extractor): "It will unzip the current file into a new folder with the name of the zip file."
aurumdigitus wrote:What XY is doing with Zips appears to be transparent
How can code behind the scenes - that you don't see - be transparent? In comparison to script code that you can read line by line? Not that you have to, though. Extractor will ask you for the location for your zipper software if it can't find it.

Be aware, however, that this setting is not necessarily portable :!: But that's not different from the way XY handles your zippers now - if it can't find the expected zipper on a system, it won't work.

aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Re: Extracting a Zip file to a folder via CTB

Post by aurumdigitus »

@ Stef123 - By Transparent meaning that nothing else had to do done on this end. If XY is doing its Zip thing by invoking some other software on the machine that is beyond my understanding.

Extractor seems to be a separate program that needs one of its required Zip utilizes to operate. Seems rather convoluted as opposed to staying within XY.

But then coding is not chemistry (which is my vocation). :)

admin
Site Admin
Posts: 60602
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Extracting a Zip file to a folder via CTB

Post by admin »

mkolaski wrote:No idea where I found this, but I've got the following set up for handling zip files...
Thanks Michael, interesting stuff! One day I will have time for this...

Pagat
Posts: 306
Joined: 09 Oct 2007 21:23
Location: Austria

Re: Extracting a Zip file to a folder via CTB

Post by Pagat »

Maybe i'm missing something, but the original question was:
aurumdigitus wrote:Can a script be written that can be placed into a CTB that will take the selected Zip, create a folder with the same name and then put the extracted files in there?
That's a simple script command:

Code: Select all

zip_extract();
Put a new user button onto the toolbar and paste the "zip_extract();" command into the "On left click:" box. Done. The selected zip file will be extracted into a subfolder with the zip files name.

(Of course, there is no error handling done. So you'll get script errors if an invalid file (no zip) is selected)

aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Re: Extracting a Zip file to a folder via CTB

Post by aurumdigitus »

Yes, yes Pagat - that is it! Exactly what was desired. You are a sagacious individual.

Reminds me of a quotation by Charles Darwin: To see what every man has seen; to think what no man has thought.

zip_extract(); The distilled essence of simplicity. One word, fourteen characters.

:appl:

Stef123

Re: Extracting a Zip file to a folder via CTB

Post by Stef123 »

aurumdigitus wrote:Yes, yes Pagat - that is it! ... The distilled essence of simplicity :appl:
Bull's eye - right on target. :appl:
Distillation 8) - an apt wording. So you're in chemistry, huh? I am impressed. Nothing more taxing than those formulas. Watching the teacher juggle flasks and vials fascinated me. But I never grasped the theory behind those cocktails - way over my head.

@ Michael
Quite some dropdown :shock: - won't help my situation (I extract small subsets only, need to get a preview instead of dumping thousands of files on disk every time) - but I can imagine this script being a great starting point to adapt and tweak to personal preference.

Post Reply