Note from @Leo:
- You do not need to use these buttons to compress/decompress RAR files.
- Opus has built-in support for unpacking RAR archives.
- If WinRAR is installed, Opus also has built-in support for creating/updating RAR archives via WinRAR without the need for custom buttons.
- The buttons in this thread can still be useful, for people who want to do things differently and call WinRAR itself, e.g. for more esoteric options WinRAR might have which Opus doesn't.
For how to use the codes in this thread, see here:
Some buttons that I use sometimes.
You can change the parameter x
to e
(decompression with path that is stored when you created archive)
Extracts files to current directory:
<?xml version="1.0"?>
<button display="both">
<label>Extract TUTAJ</label>
<tip>Extracts files to current directory</tip>
<icon1>C:\Program Files\WinRAR\WinRAR.exe,0</icon1>
<icon2>C:\Program Files\WinRAR\Uninstall.exe,1</icon2>
<function type="normal">
<instruction>cd {sourcepath}</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" x {file}</instruction>
</function>
</button>
Extracts file to dir named after the archive (removes extension):
<?xml version="1.0"?>
<button display="both" effect="off">
<guid>{4BC13510-93C1-4690-9FC5-CE3B08F9D8EE}</guid>
<label>Extract DIRX</label>
<tip>Extracts file to dir named a filename (Cut's extension)</tip>
<icon1>109</icon1>
<icon2>46</icon2>
<function type="normal">
<instruction>cd {sourcepath}</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" x "{f}" "{o|noext}\"</instruction>
</function>
</button>
Create RAR archive:
<?xml version="1.0"?>
<button display="both" effect="off" icon_size="large">
<guid>{77ABC05B-D855-4D15-94E2-4086A0B8B0C6}</guid>
<label>Add To Archive</label>
<tip>Create archive RAR</tip>
<icon1>52</icon1>
<icon2>46</icon2>
<function type="normal">
<instruction>cd {sourcepath}</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" a {f}</instruction>
</function>
</button>
Move to RAR archive:
<?xml version="1.0"?>
<button display="both" effect="off" icon_size="large">
<guid>{80EB4BAD-299B-449E-ACAF-ABFDFFACA7CB}</guid>
<label>Move to archive</label>
<tip>move files and folders to an archive</tip>
<icon1>51</icon1>
<icon2>46</icon2>
<function type="normal">
<instruction>cd {sourcepath}</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" m {f}.rar {f}</instruction>
</function>
</button>
Add to ZIP archive:
<?xml version="1.0"?>
<button display="both" effect="off" icon_size="large">
<guid>{3199946C-7232-4960-AF3B-169631604EF4}</guid>
<label>Add to ZIP</label>
<tip>Creating ZIP archive</tip>
<icon1>102</icon1>
<icon2>103</icon2>
<function type="normal">
<instruction>cd {sourcepath}</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" a -m5 {file}.zip {file}</instruction>
</function>
</button>
Extracts ONLY files with given extension:
<?xml version="1.0"?>
<button display="both" effect="off">
<guid>{B8387E1D-996D-4E55-B765-5B2DF2B04051}</guid>
<label>Extract *.xxx</label>
<tip>Extracts ONLY files with gived extension</tip>
<icon1>C:\Program Files\WinRAR\WinRAR.exe,0</icon1>
<icon2>C:\Program Files\WinRAR\Uninstall.exe,1</icon2>
<function type="normal">
<instruction>cd {sourcepath}</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" e {file} {Rs|Please, enter a file extension what you need to extract|*.}</instruction>
</function>
</button>
Warning:
Error handling: The next couple of examples lack error handling and may delete the selected archive(s) even if extraction fails (e.g. due to lack of space). See the separate thread, delete archive ONLY if no error, for a discussion about ways to resolve that while still using WinRAR.exe for extraction.
Extract and delete selected archives (rar, zip, gz, etc. - supported by winrar) to current directory:
- Creates directory from filename (without archive extension)
- Silently deletes the archives after decompression (see warning above).
<?xml version="1.0"?>
<button display="icon" effect="off">
<guid>{EA8B6CDA-4CBF-4536-86D6-3AD4E4D60E5D}</guid>
<label>Extract DIRX</label>
<tip>Extract X + delete archives</tip>
<icon1>109</icon1>
<icon2>46</icon2>
<function type="normal">
<instruction>cd {sourcepath}</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" x "{f!}" "{o|noext}\"</instruction>
<instruction>delete ALL FORCE QUIET</instruction>
</function>
</button>
Extract and delete ALL archives in current folder:
- Button automatically deselects any selection and select archives handled by WinRAR.
- Then extracts each to dir created from filename.
- Finally, deletes the archives. See warning above. Be careful! This button works silently and without any questions!
<?xml version="1.0"?>
<button display="icon" effect="off">
<guid>{4115B1A2-2338-4D56-AFBF-9F9AD4930843}</guid>
<label>Extract FOUND DIRX</label>
<tip>Automatically search for archives in current folder and Extracts it's</tip>
<icon1>109</icon1>
<icon2>46</icon2>
<function type="normal">
<instruction>cd {sourcepath}</instruction>
<instruction>select NONE</instruction>
<instruction>select all *.(zip|rar|tar|tgz|lha|ace|7z|arj|bz2|gz|lzh|z)</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" x "{f!}" "{o|noext}\"</instruction>
<instruction>delete ALL FORCE QUIET</instruction>
</function>
</button>
Note from @Leo:
- These next two were posted by Zhgwangff in another thread. We've moved them to here to make things a bit tidier.
Add all selected files to RAR in current directory with the name you specify:
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
<label>Add to RAR</label>
<tip>Add all selected files to RAR</tip>
<icon1>#goroot</icon1>
<function type="normal">
<instruction>@firstfileonly </instruction>
<instruction>cd {sourcepath}</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" a -r "{RS|Name of new RAR file|{o|noext}}.rar" {O} {allfile}</instruction>
</function>
</button>
Where /programfiles\WinRAR\WinRAR.exe
is where you WinRAR.exe is. (If it's in the default place then you won't need to change it.)
You will be prompted for the name of the archive with the default archive name being the same as the first file's name (with rar extension). You can type over the name to use a different one.
You can also change the .rar
in the button to .zip
to change the type of archive WinRAR creates.
Decompress a RAR or Zip file to directory named with it:
<?xml version="1.0"?>
<button display="both">
<label>Decompress to new folder</label>
<tip>Decompress to the Folder named with the file name</tip>
<icon1>#clippasteshortcut</icon1>
<function type="normal">
<instruction>cd {sourcepath}</instruction>
<instruction>"/programfiles\WinRAR\WinRAR.exe" x "{f}" "{o|noext}\"</instruction>
</function>
</button>