GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Copy EXTRACT HERE multiple files


I'm using Directory Opus version 11.19 x64.
I have a problem using the Copy EXTRACT HERE command on a button. Here is the code used in my button:

Select *.(Rar|zip|7z)
Go refresh

The problem is when there are many files selected. Each of the selected files has within it a copy of the same file. For each file selected Opus asks for confirmation of replacement and even I clicking "Ignore identical" it will repeat the question for each selected compressed file. Is there a way to prevent this from happening? For example, if I select all compressed files and click "Extract here" from the Winrar context menu, it asks for this replacement confirmation only once for all selected compressed files. I wanted Opus to do that.

I thank you in advance.


You should be able to replace the whole thing with one line:

Copy *.(rar|zip|7z) EXTRACT HERE WHENEXISTS=skip

(Tested in Opus 12, so it may not work as well in 11. I think we improved the way WHENEXISTS works with archives in 12 but I am not sure.)


Hi Leo,
Thank you.
It did not work for me. I think WHENEXISTS does not work well on DOpus 11. I found this while looking for solutions:

cd {sourcepath} 
"/programfiles\WinRAR\WinRAR.exe" e *.rar

This works very well for me. The problem is that it is not possible (I think) to put more than one extension on the Winrar command line. I would have to put the same two lines for each extension, and when there is no file with any of the extensions, I get a message, which is inconvenient.
But we'll keep looking. Maybe through vbscript I can do this. The detail is that I do not know how to use vbscrip in the DOpus buttons. I'm reading about it now, but it's a bit confusing for me yet.


If you cant get the Dopus native command to work this should make the winrar do what you are after. I don't have Dopus 11 handy so cant test that.

Select *.* Deselect
Select *.(rar|zip|7z)
"C:\Program Files\WinRAR\WinRAR.exe" e {filepath$} 

For such tasks I would rather use a command line tool over a UI tool. I mostly use 7zip.


Thanks wowbagger,
Your help is welcome.
Your suggestion works, but I needed to add the line "cd {sourcepath}" before the Winrar command line. Without it Winrar will try to extract the contents of the files in the directory of the Winrar executable and not in the current directory.
However, your suggestion makes the winrar work file by file and not the whole collection at once. So winrar asks each compressed file if I want to overwrite existing files, and when I click "ignore identical" this click is only for the current compressed file. When winrar extracts the next compressed file it will ask again. Using * .rar instead of {filepath $} winrar does the whole collection and only asks once. When few compressed files are fine, but when they are really many this is very inconvenient.
Again, thanks for the contribution.


The following script may do what you want. It'll select all zip, 7z, and rar files in the source and extract their contents (also to the source). If the archives contain only one file or folder, they will be extracted directly to the source, otherwise the extracted contents will be placed into a folder with the same name as the archive. If there is a filename clash, folders or files will be renamed accordingly. All extracted contents will be selected at the end of the process.

@script VBScript
Option Explicit
Dim cmd,src,srcPath,selArchive,archiveItem,archiveEnum,index,targetFolder,renamedItem
Set cmd = DOpus.Create.Command
Set src = DOpus.listers.lastactive.activetab
srcPath = src.path

If Not Right(srcPath,1) = "\" Then
  srcPath = srcPath & "\"
End If

cmd.RunCommand "Select *.(rar|zip|7z) DESELECTNOMATCH"

For Each selArchive in src.selected_files
  cmd.AddFile selArchive
  cmd.RunCommand "GetSizes"
  cmd.RemoveFile selArchive
  Set archiveEnum = DOpus.FSUtil.ReadDir(selArchive, False)

  If ((selArchive.metadata.other.filecount + selArchive.metadata.other.dircount) > 1) Then 
    If Not (DOpus.FSUtil.Exists(srcPath & selArchive.name_stem)) Then
      targetFolder = srcPath & selArchive.name_stem
      cmd.AddLine "CreateFolder " & """" & targetFolder & """" & " NOSEL"
      cmd.AddFile targetFolder
        index = index + 1
        If Not (DOpus.FSUtil.Exists(srcPath & selArchive.name_stem & " (" & index & ")")) Then
	  targetFolder = srcPath & selArchive.name_stem & " (" & index & ")"
          cmd.AddLine "CreateFolder " & """" & targetFolder & """" & " NOSEL"
          cmd.AddFile targetFolder
          index = 0
          Exit Do
        End If
    End If

    Do While (Not archiveEnum.complete)
      Set archiveItem = archiveEnum.Next
      cmd.AddLIne "Copy " & """" & archiveItem & """" & " TO " & """" & targetFolder & """"

    Do While (Not archiveEnum.complete)
      Set archiveItem = archiveEnum.Next

      If Not (DOpus.FSUtil.Exists(srcPath & Then
        cmd.AddLine "Copy " & """" & archiveItem & """" & " TO {sourcepath$}"
	cmd.AddFile srcPath &
          index = index + 1
          If Not(DOpus.FSUtil.Exists(srcPath & archiveItem.name_stem & " (" & index & ")" & archiveItem.ext)) Then
	    renamedItem = archiveItem.name_stem & " (" & index & ")" & archiveItem.ext        
	    cmd.AddLine "Copy " & """" & archiveItem & """" & " AS " & """" & renamedItem & """" & " TO {sourcepath$}"
	    cmd.AddFile srcPath & renamedItem
	    index = 0
            Exit Do
          End If
      End If

  End If


Thank you guys.
Starting from the OpusFiend code I was able to learn a lot about scripts in DOpus.
Thank you all for the great help.