WinRAR Compress/Decompress Buttons (and other)

This is turning into a 'help and support' thread, so I expect Nudel or Tanis may come along shortly and break off some of this discussion into a separate topic... but FWIW:

The 'Add To Archive' button above shouldn't ever work as it's written... because the single {f} argument is passing the name of the selected file that you want to add to an archive as the new rar filename... so you get the following error:

! dontfindme.txt: The archive is either in unknown format or damaged

Which makes sense... given the command line usage in this button example... it's sort of missing an argument and trying to overwrite the selected file as if it was already an archive.

Normally. you might want to change the command-line to something like:

"C:\Program Files\WinRAR\WinRAR.exe" a {f|ext=rar} {f}

...which would "work" but would create a new rar file for each selected file if multiple files are selected.

So, I think for ppl that would WANT such a thing, maybe youd like to break this out into two separate buttons... one that runs the command above for an Add each file to a separate Archive, and another based on what TheCoach proposed for a more rounded out generic Add To Archive button... with a small edit or two:

Coach... your command has an unecessary {allfile} argument at the end... the button still "works" as I'd imagine winrar is just ignoring that last arg... but the {O} is giving you everything you need to pass all files.

ADDITIONAL NOTE: If you have LOTS of files selected when you run the command with {O} then it may bomb out with the error in the attached screenshot. This is probably due to a limitation in the length of characters able to be passed through the 'command line'. Version 9 of Opus added a new modifier that helps us get around this... you would modify the command in TheCoachs button to run:

"C:\Program Files\WinRAR\WinRAR.exe" a -r {Rs|Specify name for archive} @{O|filem}

What thois does is use WINRAR's ability to read a text 'listfile' which contains the names of all files to process, rather than passing all file names to the executable directly on the command line. The {O|filem} expression is Opus new modified argument that takes the file names provided by {O} and copies those names to a temporary file with each of the selected file names on a new line. Using {O|file} would place all filenames on a single line in the text file... but it looks like winrar likes one file per line...

Hope this helps... let's see which forum this thread ends up in :slight_smile:. Maybe we break out the 'discussion' into a help and support thread, and get LITWINCZUK and Coach to agree on reposting buttons with some of these considerations taken into account; and which have been tested and are known to work.

@LITWINCZUK: you've been generous in providing your way of doing things to others in the forums and mistook comments of mine in another thread for criticism/sarcasm... hopefully you don't feel the same about this post... just offering my views on things... cheers!

In case of archives in parts (rar, r01, r02...) after extraction, it deletes ONLY the 'rar' file, leaving the others


I'm trying to unrar multiple selected files with a button.
The WinRAR context menu did it very well, you select the files, then right click on them, then "Extract Here", and the files start to be unrared in the same thread. (I mean, if you select 3 files and unrar them, you don't have 3 concurrents or 3 successives Winrar windows.)
Winrar is able to decompress them in a row.

I'm trying to reproduce this comportment with a dopus button, here the command I have :

@sync "C:\Program Files\WinRAR\WinRAR.exe" x  {f} "E:\tmp\"

It's almost the same comportment as Winrar, but it is still in 3 different jobs, Dopus throws the first file to Winrar, then Winrar is closed, then dopus sends the second one, and so on...
plus you have this annoying "always on top" windows titled "File function - Directory Opus".

Does someone find a way to make dopus act like Winrar or at least to hide this "on top" window ?

(Aside: There's no need for the @sync there, by the way. It won't have any effect.)

{f} will only turn into a single filename so if you have three files selected (File1.rar, File2.rar and File3.rar, all in C:\ for the sake of argument) then Opus will turn your line into three lines, one for each file:

"C:\Program Files\WinRAR\WinRAR.exe" x C:\File1.rar "E:\tmp"
"C:\Program Files\WinRAR\WinRAR.exe" x C:\File2.rar "E:\tmp"
"C:\Program Files\WinRAR\WinRAR.exe" x C:\file3.rar "E:\tmp"

It should now be obvious why you get three WinRARs appearing, one after the other (or all at once, depending on how WinRAR is written; some programs run in the background and it's up to the program, not Opus).

If you want to only get a single WinRAR then, of course, you need to pass all of the filenames to it at once somehow. There are several ways to do this with Opus, {F} being the usual one. If you use {F} instead of {f} then Opus will list all three files on a single command:

"C:\Program Files\WinRAR\WinRAR.exe" x C:\File1.rar C:\File2.rar C:\File3.rar "E:\tmp"

I don't know whether WinRAR will recognise that command line, though. If it doesn't then you might have to try something different. Opus can also write the list of filenames into a temporary text file, then pass that text file to the program (see here), which works with some things (but is much less common).

I've filed a feature request for a way to disable the progress dialog for certain functions but I think if you make the command run as a single line then it may suppress the progress dialog anyway so try the stuff above and see how you get on.

Use {f|noext} instead of {f}

Can we keep questions about how to use WinRAR to the Coffeeshop forum?

The Buttons & Toolbars forum is meant to be a place where people can find pre-made buttons & toolbars to do useful things without having to wade through unrelated questions and answers.

We aim for this because we ourselves get frustrated when looking for things on other forum-based sites where download threads turn into 50-page monsters with 10 interwoven discussions that get in the way of finding all the information about the download itself. Questions and answers specifically about the download are fine (but may be edited/cleaned up/deleted after a while if they don't look like they'll be useful to other people or can be consolidated into a single informative post/paragraph) but I think we're straying away from that here.

If this was a dedicated WinRAR forum then all of these questions about the WinRAR command-line would have been separate threads/posts and I don't want this thread to turn into a miniature, flattened WinRAR forum. :slight_smile:

Questions about using Opus should go to the Help & Support forum and questions about using other programs (e.g. WinRAR) should go to the support forum/email contact for the program in question, since they should know more about the program than the Opus community, but feel free to also ask in the Coffeeshop if you think someone here might know.

When you find an answer to a question and that answer seems useful to people interested in a download then by all means post the information to the download thread.

I've added two extra WinRAR buttons from Zhgwangff to the bottom of the root post.

I also tidied up the thread from four pages down into a single page by deleting/consolidating a lot of question & answer posts (but keeping the answers themselves where they seemed relevant to the thread).

(If you think it looks like a mess now you should've seen it before! :slight_smile:)

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
   <label>Add to RAR</label>
   <tip>Add all selected files to RAR</tip>
   <function type="normal">
      <instruction>@firstfileonly </instruction>
      <instruction>cd {sourcepath}</instruction>
      <instruction>&quot;/home\plugins\wrar\WinRAR.exe&quot; a -r {Rs|Name of New file|{o|noext}.rar} {O} {allfile}</instruction>

I found it will not work when you type a name of a new file with space, for example, it will be ok when the new name is "newfile", but when it is "new file", you will got "new.rar" rather than "new file.rar"

It needed quotes around the {Rs}. I've fixed the version in the root post.

I also changed it to use {RS} instead of {Rs}, so the default name is selected to allow you to type over it as soon as the name prompt opens.

I also moved the .rar extension to after the {RS} code so that you don't have to worry about typing over the extension when changing the archive name.

Finally, while I was at it, I changed the path to /programfiles\WinRAR\WinRAR.exe as I figure that'll work out-of-the-box for more people. Hope you don't mind.

Thanks to Leo, it works!

These are all great buttons - thanks for posting them :slight_smile: The only button that I'm trying to create that is not listed here, is to select multiple archives, and extract all of them to one folder that I'm prompted to create (in the source) using digstring. I've fiddled around with the commands, but can't seem to get it working. The button below extracts all the selected archives into separate folders in the source, rather than one folder.

"C:\Program Files\WinRAR\WinRAR.exe" x "{f}" "{o|noext}\"

I'm trying to modify the above button to either:

  1. Extract all selected archives to one folder that I'm prompted to create (in the source)
  2. Extract all selected archives to a folder that is automatically created using the filename of the first selected file.

If anyone has any ideas to point me in the right direction, please share :slight_smile:

After fiddling around with different commands, I've now got a button that seems to work. When pressed, the user will be prompted to create a folder, which all currently selected archives will be extracted to:

@runonce:@set dirname={dlgstringS|Enter name|{file$|noext}}
"C:\Program Files\WinRAR\WinRAR.exe" x "{f!}" "{$dirname}\"

I also wrote out another button for 7-zip which does exactly the same thing, just the commands had to be changes slightly:

@runonce:@set dirname={dlgstringS|Enter name|{file$|noext}}
"D:\Portable\7-ZipPortable\App\7-Zip\7zG.exe" x "{f!}" -o"{$dirname}\"

Both buttons seem to work very well. But I'm not a very proficient coder, so if anyone has any suggestions on how I could tighten it up or go about it in a different way, please give a shout :slight_smile:

How do I use the code for the buttons listed in this post. I see the xml but cannot see where it is used when creating a button.


See the sticky post at the top of this Buttons & Toolbars area and also linked in the FAQs.

This question suggests that you are at the bottom of what could be a long and steep learning curve with DOpus. There is plenty of stuff in the various sections and FAQs here to explain what to do.

Meanwhile, until the real experts come in:

  • Right click a toolbar
  • Customise
  • Right click a toolbar again
  • New > New Button
  • Right click on the button
  • Paste code

You can then move the button to somewhere more convenient.

That's just one way to do it.

If the button does not recognise the code as valid, it will not allow you to paste.

Note: It's described in the sticky post Leo referred ht354 to of course - but figured I'd mention here that you don't even need to click "New >>New Button"... if you've copied "button code" from a post here on the forum (complete with the xml and button tags and all that) then simply copying that text from the web browser to your clipboard will let you 'paste' that text to a toolbar while in Customize mode and will actually CREATE the new button for you...


  • Right click a toolbar
  • Click Customise
  • Right click a toolbar again
  • Select Paste
  • Click 'OK' out of Customize mode[/code]

Clicking Insert New->New Button and THEN pasting will result in you having TWO new buttons on your toolbar - one of which will be 'empty' and not do anything :slight_smile:...

THanks for the actual "Make a Button" steps, but the real important thing is what do I do with the "code" that is posted for each button.

When I go in and choose advanced and paste in the code, I get errors.

So what or rather how do I get the supplied code in this thread to act with buttons?

Read the solutions provided to you - they make it quite clear what to do with the xml code, particularly the information given by Leo which will lead you to the FAQ explaining this in great detail.

Excellent scripts. Thanks

I have a context menu entry (for all files and folders) that does this action:

"/programfiles\winrar\winrar.exe" a "{dlgstring|New file name|{date|yy-MM-dd} {time|}}.rar" {allfile$}

It works pretty well unless it's used for files on my memory stick (pendrive) - WinRAR says ".rar: Cannot open [file I selected] \ cannot find this file."
It seems that it's because when used on memory stick, working dir (start in dir) is set incorrectly (not equal to the active lister path).
Setting start in = {sourcepath} for buttons works ok but I cant set "start in" dir for context menu entries.

(Edit May 2011: Most of the examples have been updated to explicitly CD {sourcepath} and this advice would break that change. WinRAR v4 now has a command-line argument that lets you specify the directory it uses for temporary files so you should use that if you need to override its default behaviour. Or just use the built-in RAR support in Opus so you don't have to worry about all this. :slight_smile:)

You can use the CD command to set the working dir. If you find a button you've set the "start in" folder on and click Advanced, it'll show you how to use the CD command, and that should work in a context menu as well.