Script to "Extract here..." in WinRAR

Discuss and share scripts and script files...
ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Script to "Extract here..." in WinRAR

Post by ivan »

I would be very grateful if someone is able to write a XYScript for me to extract file(s) from RAR archive(s) that I select. Ideally things will go like this:

1. Select file(s) to unrar.
2. Press a button (a hot key that would be associated with a script)
3. Open a beer :P

For those who are familiar with Windows Command Scripts here's an example of how it would look in a batch script:

Code: Select all

@REM ------- BEGIN demo.cmd ----------------
@setlocal
@echo off
set path="C:\Program Files\WinRAR\";%path%
for /F %%i in ('dir /s/b *.rar') do call :do_extract "%%i"
goto :eof

:do_extract
echo %1
mkdir %~1.extracted
pushd %~1.extracted
unrar e %1
popd

REM ------- END demo.cmd ------------------
I hope it helps to make situation clearer and to create a script :)

eurytos
Posts: 200
Joined: 29 Jan 2008 15:53

Post by eurytos »

you could set the default action in winrar to 'extract here' and then select the files and double click. Unless I am missing something I don't really see a need for a script?

I don't remember the exact terminology they use for 'extract here' in the application since I do not use it anymore but it is something along those lines.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

You don't need script, just a UDC "Open With" with this as Application (on Multiple instance) :

Code: Select all

"WinRAR" x <items>
Optionally, you can use this instead to "Extract Each to Subfolder" :

Code: Select all

"WinRAR" x -ad <items>
Proud XYplorer Fanatic

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Post by TheQwerty »

jacky wrote:You don't need script, just a UDC "Open With" with this as Application (on Multiple instance) :

Code: Select all

"WinRAR" x <items>
Optionally, you can use this instead to "Extract Each to Subfolder" :

Code: Select all

"WinRAR" x -ad <items>
To be on the safe side you might want to add "--" before <items> in either of those.

That signifies the end of the switches list and will prevent WinRAR from attempting to parse an item starting with "-" as a switch.

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

I know it's possible to extract with a couple of clicks, but I prefer a one finger (pressing a button) solution :P

Also, most of the time not every single file in the dir is a RAR file. So just opening isn't enough, it needs to extract in the same dir as the selected file...

bergfex
Posts: 188
Joined: 07 Sep 2007 19:06

Post by bergfex »

ivan wrote:I know it's possible to extract with a couple of clicks, but I prefer a one finger (pressing a button) solution :P
Just assign a KS to the UDC.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

TheQwerty wrote:To be on the safe side you might want to add "--" before <items> in either of those.
Right, good one, thanks :)

And yeah, as bergfex said just assign a KS and it will only take one key. And once CTB will be there, you will even be able to create you own TB button to do the same, so you'll be able to have it in one click also!
Proud XYplorer Fanatic

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

The Open With UDC isn't effective for the purpose because it just opens, it doesn't extract as necessary ;)

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

ivan wrote:The Open With UDC isn't effective for the purpose because it just opens, it doesn't extract as necessary ;)
Yes, it does. If you specify a command line with action x (for extract) as showed in the examples above, it will extract the selected archives and not open it. I should know, whenever I need to extract an archive I only press one key (KS for such UDC) !
Proud XYplorer Fanatic

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

Well, it doesn't work for me. Perhaps I'm doing something wrong and just don't see it. Any chance of a step-by-step? Thanks in advance :)

eurytos
Posts: 200
Joined: 29 Jan 2008 15:53

Post by eurytos »

If winrar is not in your path you may have to use:
"c:\Program Files\winrar\winrar.exe"
instead of:
"WinRAR"


The path could be different depending on where you installed it.

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

nope, doesn't work. still just opens the RAR and doesn't extract here.

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

Post by admin »

ivan wrote:nope, doesn't work. still just opens the RAR and doesn't extract here.
Works fine here (WinRAR 3.0). Maybe you check your WinRAR version/manual on commandline parameters...

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

Here's the view of UDC, what am I doing wrong? WinRAR 3.71 is intalled.

Image

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

Shouldn't the "x <items>" be on the Application line and not the Caption? Since the Caption is just for display...right???
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Post Reply