7z, RAR, and Zip Buttons

[Note: Opus 10 has built-in support for creating 7z, RAR and Zip archives. Older versions didn't support 7z and had read-only RAR support, so these buttons may still be useful there, but with newer versions of Opus you can probably skip this thread unless you're looking for something special.]

I have some buttons I created that will create a 7z file from the contents of a folder, convert from ZIP to 7z, UnRar a file to a folder, convert a RAR to a ZIP and a couple of others. I know some of these are available via context menu but if you don't have the full blown Rar or 7z installed, this should help you out.

Attached is a zip file that has DOS versions of 7z, RAR, and UnRAR that you must have in order for any of these scripts to work. Unzip and copy to system32 or use the setup.cmd

Get the RarFilename, create folder and extract

<?xml version="1.0"?>
<button display="label">
	<label>UnRar to \fldFileName</label>
	<tip>UnRar to \fldFileName</tip>
	<icon1>84</icon1>
	<function type="batch">
		<instruction>@echo off</instruction>
		<instruction>color 0b</instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo D I R E C T O R Y  O P U S </instruction>
		<instruction>echo UnRar for DOpus v9.x</instruction>
		<instruction>echo by Sam Hull               </instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo. </instruction>
		<instruction />
		<instruction>:_extract7z</instruction>
		<instruction>  echo Creating folder from filename and extracting Rar file...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  UnRar x {filepath$} {filepath$|noext}\</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo done...</instruction>
		<instruction />
		<instruction>goto _end</instruction>
		<instruction />
		<instruction />
		<instruction>:_end</instruction>
		<instruction>  ping -n 5 127.0.0.1 &gt; nul</instruction>
	</function>
</button>

Convert Rar to Zip

<?xml version="1.0"?>
<button display="label">
	<label>Rar 2 Zip</label>
	<tip>Rar 2 Zip</tip>
	<icon1>84</icon1>
	<function type="batch">
		<instruction>@echo off</instruction>
		<instruction>color 0b</instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo D I R E C T O R Y  O P U S </instruction>
		<instruction>echo UnRar for DOpus v9.x</instruction>
		<instruction>echo by Sam Hull               </instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo. </instruction>
		<instruction />
		<instruction>:_extract7z</instruction>
		<instruction>  echo Creating folder from filename and extracting Rar file...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  UnRar x {filepath$} {filepath$|noext}\</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo done...</instruction>
		<instruction>  echo. </instruction>
		<instruction>  </instruction>
		<instruction>:_createzip</instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo. </instruction>
		<instruction>  echo Creating zip file from extracted files...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  7za a -tzip {filepath$|ext=zip} {filepath$|noext}\* -r</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo done...</instruction>
		<instruction>  </instruction>
		<instruction>goto _end</instruction>
		<instruction>:_end</instruction>
		<instruction>  ping -n 5 127.0.0.1 &gt; nul</instruction>
	</function>
</button>

Convert 7z to Zip

<?xml version="1.0"?>
<button display="both">
	<label>Convert 7z to Zip</label>
	<tip>Convert 7z to Zip</tip>
	<icon1>C:\Program Files\7-Zip\7zFM.exe,1</icon1>
	<function type="batch">
		<instruction>@echo off</instruction>
		<instruction>color 0b</instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo D I R E C T O R Y  O P U S </instruction>
		<instruction>echo 7z to Zip for DOpus v9.x</instruction>
		<instruction>echo by Sam Hull           </instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo. </instruction>
		<instruction />
		<instruction>:_zipcheck</instruction>
		<instruction>  if exist {filepath$|ext=zip} goto _prevdone</instruction>
		<instruction />
		<instruction>:_extract7z</instruction>
		<instruction>  echo Creating folder from filename and extracting 7z...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  7za x {filepath$} -o{filepath$|noext} -r</instruction>
		<instruction>  echo.</instruction>
		<instruction />
		<instruction>:_createzip</instruction>
		<instruction>  echo Creating zip file from extracted files...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  7za a -tzip {filepath$|ext=zip} {filepath$|noext}\* -r</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo done...</instruction>
		<instruction>goto _end</instruction>
		<instruction />
		<instruction>:_prevdone</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo zipfile already exists, exiting...</instruction>
		<instruction>  echo.</instruction>
		<instruction>goto _end</instruction>
		<instruction />
		<instruction>:_end</instruction>
		<instruction>  ping -n 5 127.0.0.1 &gt; nul</instruction>
	</function>
</button>

Dir to 7z

<?xml version="1.0"?>
<button display="both">
	<label>Dir to 7z</label>
	<tip>Dir to 7z</tip>
	<icon1>C:\Program Files\7-Zip\7zFM.exe,0</icon1>
	<function type="batch">
		<instruction>@echo off</instruction>
		<instruction>color 0b</instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo D I R E C T O R Y  O P U S </instruction>
		<instruction>echo Dir to 7z for DOpus v9.x</instruction>
		<instruction>echo by Sam Hull               </instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo. </instruction>
		<instruction />
		<instruction />
		<instruction>:_createzip</instruction>
		<instruction>  echo Creating 7z file...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  7za a -t7z {filepath$|noext}.7z {filepath$}</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo done...</instruction>
		<instruction>goto _end</instruction>
		<instruction />
		<instruction>:_end</instruction>
		<instruction>  ping -n 5 127.0.0.1 &gt; nul</instruction>
	</function>
</button>

Dir to 7z (Remove dir when done)

<?xml version="1.0"?>
<button display="both">
	<label>Dir to 7z (Remove Dir)</label>
	<tip>Dir to 7z (Remove Dir)</tip>
	<icon1>C:\Program Files\7-Zip\7zFM.exe,0</icon1>
	<function type="batch">
		<instruction>@echo off</instruction>
		<instruction>color 0b</instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo D I R E C T O R Y  O P U S </instruction>
		<instruction>echo Dir to 7z for DOpus v9.x</instruction>
		<instruction>echo by Sam Hull               </instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo. </instruction>
		<instruction />
		<instruction />
		<instruction>:_createzip</instruction>
		<instruction>  echo Creating 7z file...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  7za a -t7z {filepath$|noext}.7z {filepath$}</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo done...</instruction>
		<instruction>    ping -n 5 127.0.0.1 &gt; nul</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo Removing Dir {filepath$}...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  rd /s /q {filepath$}</instruction>
		<instruction>goto _end</instruction>
		<instruction />
		<instruction>:_end</instruction>
		<instruction>  ping -n 5 127.0.0.1 &gt; nul</instruction>
	</function>
</button>

Dir to Zip

<?xml version="1.0"?>
<button display="both">
	<label>Dir to Zip</label>
	<tip>Dir to Zip</tip>
	<icon1>C:\Program Files\7-Zip\7zFM.exe,1</icon1>
	<function type="batch">
		<instruction>@echo off</instruction>
		<instruction>color 0b</instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo D I R E C T O R Y  O P U S </instruction>
		<instruction>echo Create Zip from Dir for DOpus v9.x</instruction>
		<instruction>echo by Sam Hull               </instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo. </instruction>
		<instruction />
		<instruction>:_zipcheck</instruction>
		<instruction>  if exist {filepath$|ext=zip} echo Zip file already exists, exiting job&amp;goto _prevdone</instruction>
		<instruction />
		<instruction>:_createzip</instruction>
		<instruction>  echo Creating zip file from extracted files...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  7za a -tzip {filepath$|ext=zip} {filepath$}* -r</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo done...</instruction>
		<instruction>goto _end</instruction>
		<instruction />
		<instruction>:_prevdone</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo zipfile already exists, exiting...</instruction>
		<instruction>  echo.</instruction>
		<instruction>goto _end</instruction>
		<instruction />
		<instruction>:_end</instruction>
		<instruction>  ping -n 5 127.0.0.1 &gt; nul</instruction>
	</function>
</button>

Hope someone finds these useful.

One other benefit, you can highlight multiple folders and it will create separate archive files, one for each folder.

~ Sam
ziptools.zip (404 KB)
archive tools.dop (9.36 KB)

Convert Rar to 7Zip (+ deleting original file)

<?xml version="1.0"?>
<button display="both">
	<label>Rar 2 7z</label>
	<tip>Rar 2 7z</tip>
	<icon1>#ziptoolkit</icon1>
	<function type="batch">
		<instruction>@echo off</instruction>
		<instruction>color 0b</instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo D I R E C T O R Y  O P U S </instruction>
		<instruction>echo UnRar for DOpus v9.x</instruction>
		<instruction>echo by Sam Hull  </instruction>
		<instruction>echo modified by Elypter</instruction>
		<instruction>echo multiple files are possible </instruction>
		<instruction>echo i suggest only execute in containing folder. if it fails temp files pile up.</instruction>
		<instruction>echo original and temporary files are being deleted         </instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo. </instruction>
		<instruction>:_extract7z</instruction>
		<instruction>  echo Creating folder from filename and extracting Rar file...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  UnRar x &quot;{filepath$}&quot; &quot;{filepath$|noext}&quot;\</instruction>
		<instruction>  echo.</instruction>
		<instruction>  echo done...</instruction>
		<instruction>  echo. </instruction>
		<instruction>  </instruction>
		<instruction>:_createzip</instruction>
		<instruction>echo --------------------------------------------------</instruction>
		<instruction>echo. </instruction>
		<instruction>  echo Creating zip file from extracted files...</instruction>
		<instruction>  echo.</instruction>
		<instruction>  7z a &quot;{filepath$|ext=7z}&quot; &quot;{filepath$|noext}&quot;\* -r</instruction>
		<instruction>  echo.</instruction>
		<instruction>  del &quot;{filepath$}&quot;</instruction>
		<instruction>  rd /s /q &quot;{filepath$|noext}&quot;</instruction>
		<instruction>  echo done...</instruction>
		<instruction>  </instruction>
		<instruction>goto _end</instruction>
		<instruction>:_end</instruction>
		<instruction>  ping -n 2 127.0.0.1 &gt; nul</instruction>
	</function>
</button>

rar_2_7z_button.zip (225 Bytes)