Zip: Possible extract into a folder with same zip file name?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
cadu
Posts: 237
Joined: 18 Mar 2012 21:50

Zip: Possible extract into a folder with same zip file name?

Post by cadu » 07 Apr 2019 13:57

Hi,

I'd appreciate your help.

I'm using the command File | File Special | Extract Here (#280), which makes some messy if the zip has plenty of files in the root.

Is there any workaround to extract zip into a folder with the same zip file name?

For instance:
1) c:\zipfilename.zip

After extract, a folder "zipfilename" should be created and the content put into it:
2) c:\zipfilename\zip extracted content

Thank you very much!

highend
Posts: 8302
Joined: 06 Feb 2011 00:33

Re: Zip: Possible extract into a folder with same zip file name?

Post by highend » 07 Apr 2019 14:00

Right click it, Zip - Extract to <name of zip file>\

Configuration | General | Menus, Mouse, Safety | Context Menus | File List...
[x] Zip
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

cadu
Posts: 237
Joined: 18 Mar 2012 21:50

Re: Zip: Possible extract into a folder with same zip file name?

Post by cadu » 07 Apr 2019 14:20

highend wrote:
07 Apr 2019 14:00
Right click it, Zip - Extract to <name of zip file>\

Configuration | General | Menus, Mouse, Safety | Context Menus | File List...
[x] Zip
Thank you for your reply. I could make ZIP to work when I set XYplorer inbuilt menu.
However, I use most of the time the 64-bit context menu, in which there is no XYplorer Zip menu.
In that case, do you know if it is possible to implement a script/command to "Zip - Extract to <name of zip file>", making this available in the breadcrumb menu, or a user button?

highend
Posts: 8302
Joined: 06 Feb 2011 00:33

Re: Zip: Possible extract into a folder with same zip file name?

Post by highend » 07 Apr 2019 14:22

Sure, there is the zip_extract() command...
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

cadu
Posts: 237
Joined: 18 Mar 2012 21:50

Re: Zip: Possible extract into a folder with same zip file name?

Post by cadu » 07 Apr 2019 15:26

highend wrote:
07 Apr 2019 14:22
Sure, there is the zip_extract() command...
Worked perfectly. Thank you very much!

Leito
Posts: 535
Joined: 26 Sep 2016 15:37
Location: Windows 10 1809 x64

Re: Zip: Possible extract into a folder with same zip file name?

Post by Leito » 08 Apr 2019 09:55

In case you're interested, this is the script I use with 7-Zip for extraction in order to support all archive formats (more than zip_extract() anyway). It extracts to the current folder if there is only one item in the root of the archive, or else in a new folder like you desire.

Code: Select all

/* Extracts the selected archives using 7-Zip.
 *
 * For each archive, if it contains:
 * - Only one item in the archive root: the content is extracted directly to the current folder.
 * - More than one item in the archive root: the content is extracted to a new folder.
 */
"ExtractWith7Zip"
    // Check if there's a file/folder selected
    if (Get("CountSelected") == 0) {
        Msg("Please select at least one file to extract.", 16);
        End(1);
    }

    $filesPaths = Get('SelectedItemsPathNames', '|');
    foreach ($filePath, $filesPaths, "|") {
        // Get the list of files/folders present in the root of the zip file
        $zipContent = Zip_List2($filePath);

        // Compute the number of files/folders present in the root of the zip file
        $filesInZipRoot = GetToken($zipContent, "count", "|");

        if ($filesInZipRoot > 1) {
            // Extract to a new folder
            Run("""C:\Program Files\7-Zip\7zG.exe"" x ""$filePath"" -o*");
        } else {
            // Extract to the current folder
            Run("""C:\Program Files\7-Zip\7zG.exe"" x ""$filePath"" -o""<curpath>""");
        }
    }

cadu
Posts: 237
Joined: 18 Mar 2012 21:50

Re: Zip: Possible extract into a folder with same zip file name?

Post by cadu » 08 Apr 2019 13:26

Leito wrote:
08 Apr 2019 09:55
It extracts to the current folder if there is only one item in the root of the archive, or else in a new folder like you desire.
This is handy! Useful script!
Thanks for sharing @Leito.
Last edited by cadu on 08 Apr 2019 17:00, edited 1 time in total.

RalphM
Posts: 1256
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Zip: Possible extract into a folder with same zip file name?

Post by RalphM » 08 Apr 2019 16:47

@cadu: Could I ask you kindly to consider in the future, whether there is anything gained by using a full quote of a post that is just above yours?
It makes perfect sense to use (preferable) partial quotes to show what earlier context you are referring to in a reply (especially when there is a discussion going on between several users and your replying to a post a bit further up) but there is nothing to be gained by a full quote as above.

Thanks
Ralph :-)
(OS: W10 1809 Home x64 - XY: Current beta)

Post Reply