Creating "extract here" button when inside archive

Try

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    var fsu = DOpus.FSUtil();
    cmd.deselect = false;

    var archivePath = String(tab.path).replace(/(.*\.)(zip|7z|rar|iso)\\?.*/i, '$1$2');
    var targetPath = fsu.NewPath(archivePath).Parent();
    cmd.RunCommand('COPY EXTRACT=sub FILE="' + archivePath + '" TO="' + targetPath + '"');
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>37666</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    var tab = clickData.func.sourcetab;</instruction>
		<instruction>    var fsu = DOpus.FSUtil();</instruction>
		<instruction>    cmd.deselect = false;</instruction>
		<instruction />
		<instruction>    var archivePath = String(tab.path).replace(/(.*\.)(zip|7z|rar|iso)\\?.*/i, &apos;$1$2&apos;);</instruction>
		<instruction>    var targetPath = fsu.NewPath(archivePath).Parent();</instruction>
		<instruction>    cmd.RunCommand(&apos;COPY EXTRACT=sub FILE=&quot;&apos; + archivePath + &apos;&quot; TO=&quot;&apos; + targetPath + &apos;&quot;&apos;);</instruction>
		<instruction>}</instruction>
	</function>
</button>

How to

How to use buttons and scripts from this forum

1 Like