Extracting a zip file to its own folder

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Neddy
Posts: 2
Joined: 24 Dec 2013 08:01

Extracting a zip file to its own folder

Post by Neddy »

Hi all. I'm a new XY user trying to meld XY into my subconscious like I have with Windows Explorer.

Something I do a lot is extract compressed archive files (mostly zips) to their own folder.
Like extract the contents of "my.zip" to a new folder named "my".
There's an option to do this very thing right in XYPlorer: right-click, then "Zip" then "Extract to <my>\"

But there doesn't seem to be a keyboard shortcut for that. I tried to make a new kbd shortcut but couldn't find this action. Where's it at?

(I also found an add on script called Extractor posted herebut I'm hoping to learn how find these actions.

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

Re: Extracting a zip file to its own folder

Post by highend »

There isn't any "zip to" action that can be bound to a keyboard shortcut. Not every single context menu command is available as such but it can be scripted...
One of my scripts helped you out? Please donate via Paypal

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: Extracting a zip file to its own folder

Post by 40k »

Best way to go about this is write a script.
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

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

Re: Extracting a zip file to its own folder

Post by highend »

Advantage: Works for all selected files, not only a single one...

Code: Select all

    foreach($item, get("SelectedItemsPathNames", "|"), "|") {
        if ($item != "" && getpathcomponent($item, "ext") == "zip") {
            zip_extract($item, getpathcomponent($item, "base"), , "|");
        }
    }
    status "Extraction of archive(s) completed...", "00800000", "ready";
One of my scripts helped you out? Please donate via Paypal

Neddy
Posts: 2
Joined: 24 Dec 2013 08:01

Re: Extracting a zip file to its own folder

Post by Neddy »

Highend, that sounds perfect.
Can someone help me understand the script a bit?

Code: Select all

    foreach($item, get("SelectedItemsPathNames", "|"), "|") {
So we'll be looping through each selected file and in each iteration of the loop $item will refer to a different selected file.

Code: Select all

        if ($item != "" && getpathcomponent($item, "ext") == "zip") { 
If the file's extension is "zip", stuff happens, otherwise it's skipped.
Is this case insensitive?

Code: Select all

            zip_extract($item, getpathcomponent($item, "base"), , "|"); 
This is the interesting one.

Looks like the call for the zip_extract function is:
zip_extract(zipfile, path, [itemlist], [separator="|"])

Why the pipe as the 4th param? Is it possible getpathcomponent($item, "base") could return multiple files? What could cause that? And why would they be pipe separated?

Thanks so much for the replies everyone :-)

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

Re: Extracting a zip file to its own folder

Post by highend »

Is this case insensitive?
Yes
Why the pipe as the 4th param?
To separate items in the itemlist.
Is it possible getpathcomponent($item, "base") could return multiple files?
No, but why should it? There is a while | foreach loop to do such things.
What could cause that? And why would they be pipe separated?
Never thought of it...
One of my scripts helped you out? Please donate via Paypal

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Extracting a zip file to its own folder

Post by nerdweed »

The pipe character isn't accepted as a valid file name and hence it becomes a good choice as a delimeter.

CookieMonster

Re: Extracting a zip file to its own folder

Post by CookieMonster »

Is it possible to extract a single file from a zip file ? I love XY has built in compressor, as I migrate XY to be my one stop program for file managing and much more.

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

Re: Extracting a zip file to its own folder

Post by highend »

rtfm "idh_scripting_comref.htm#idh_sc_zip_extract";
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: Extracting a zip file to its own folder

Post by CookieMonster »

highend wrote:rtfm "idh_scripting_comref.htm#idh_sc_zip_extract";
FYI, I read the manual, not the scripting portion. I loaded the command in the address bar, nothing happens :?:

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

Re: Extracting a zip file to its own folder

Post by RalphM »

I added two colons at the start, now paste this into the AB and hit enter.

Code: Select all

::rtfm "idh_scripting_comref.htm#idh_sc_zip_extract";
Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

CookieMonster

Re: Extracting a zip file to its own folder

Post by CookieMonster »

RalphM wrote:I added two colons at the start, now paste this into the AB and hit enter.

Code: Select all

::rtfm "idh_scripting_comref.htm#idh_sc_zip_extract";
Too many languages and keyboard short-cuts for programs I use; XY is always last to remember :)

CookieMonster

Re: Extracting a zip file to its own folder

Post by CookieMonster »

Code: Select all

text zip_extract("<network drive>\<folder>\<zipfile>","<folder>","<specific file I only want extracted>");
I get a popup that gives me the folder in which I wanted to extract the specific file too but no file is extracted ?

autocart
Posts: 1246
Joined: 26 Sep 2013 15:22

Re: Extracting a zip file to its own folder

Post by autocart »

Sorry, but the way you posted it, it can't work. (These <...> that you used are just not recognized by XY. I dunno how you came up with that.)
The last example in the help file should be exactly what you want, I think, and it works, at least on my machine.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Extracting a zip file to its own folder

Post by bdeshi »

@CookieMonster: Do you have write access to the target path? (I ask because apparently it's a net path)
Try extracting to a local path.

@autocart: I'm pretty sure CM used those <terms> as placeholders in the post only, and not in the script. :)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply