Page 1 of 1
Zip: Possible extract into a folder with same zip file name?
Posted: 07 Apr 2019 13:57
by cadu
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!
Re: Zip: Possible extract into a folder with same zip file name?
Posted: 07 Apr 2019 14:00
by highend
Right click it, Zip - Extract to <name of zip file>\
Configuration | General | Menus, Mouse, Safety | Context Menus | File List...
[x] Zip
Re: Zip: Possible extract into a folder with same zip file name?
Posted: 07 Apr 2019 14:20
by cadu
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?
Re: Zip: Possible extract into a folder with same zip file name?
Posted: 07 Apr 2019 14:22
by highend
Sure, there is the zip_extract() command...
Re: Zip: Possible extract into a folder with same zip file name?
Posted: 07 Apr 2019 15:26
by cadu
highend wrote: ↑07 Apr 2019 14:22
Sure, there is the zip_extract() command...
Worked perfectly. Thank you very much!
Re: Zip: Possible extract into a folder with same zip file name?
Posted: 08 Apr 2019 09:55
by Leito
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>""");
}
}
Re: Zip: Possible extract into a folder with same zip file name?
Posted: 08 Apr 2019 13:26
by cadu
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.
Re: Zip: Possible extract into a folder with same zip file name?
Posted: 08 Apr 2019 16:47
by RalphM
@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