Custom command to archive and encrypt

I am trying to write a script to

  1. Sort and filter the current lister, then select the first file in the list (I am able to do this).
  2. Archive the selected files using the first file as the archive name and encrypt with password (I am able to do this but can not encrypt).

Since I could not script the encryption, I tried to use the ADDTOARCHIVE command to bring up the dialog box prepopulated

  1. Step one above still works
  2. Step two does not work.
    Problem 1: The file name used in the dialog box is always the file selected before the script runs not the file selected during the script.
    Problem 2: I am unable to get the password prepopulated
    Problem 3: I can not set the NO SPLIT option as given in the example command from the help file "Copy ADDTOARCHIVE=.zip,nosplit,nofullpaths". The split box remains checked.

Question:
Is there a way to script DOpus to archive and encrypt?

Thanks,
Bob

Problem 1: If you show your script so far, it'll be much easier to understand exactly what you're doing and (if possible) work out how to make it do the remaining parts.

Problem 2: You can't pre-populate the password fields, at least not currently. (If the password was stored in the button it wouldn't be particularly secure; anything that could read your Opus config files would know the password. But I guess that's a trade-off which might be acceptable if the data isn't very sensitive.)

Problem 3: The nosplit parameter works okay for me in 10.0.1.6.

Here is what I have working so far.

Set SORTBY=name SORTREVERSE=Off
Select DSL_Bundle FILTER FILTERFLAGS=hidenomatch Type=Files
Select First "Used to make this file the active selection so that the name of this file is the name of the archive file (AFN)
Select ALLFILES
Copy ARCHIVE HERE
Select INVERT

Comments:
Instead of sorting and using Select First. I would have liked to select the file (AFN) from the filtered set (DSL_Bundle) using a PATTERN but this method did not change the active selection. For example, if I had three files in the filtered set and file 2 was selected in the lister when the above script was executed. Then file 2 would have the little white box around it after the select all files command, regardless of any results from the Select PATTERN commands I tried, and the name of the archive would be the file name for file 2. But sorting and using Select First overrides the currently selected file.

The last command selects the newly created zip file and deselects the other files.

This is a personal productivity tool so I am fine putting the password in the code

Another approach I am thinking of is to pass the files to wzzip (command line add-on) like this: @sync:C:\Program Files\WinZip\WZZIP.EXE -sPassword -ycAES256 {filepath}.

Thanks for your help,
Bob

As an aside, you won't get anything useful by doing Select FIRST followed by Select ALLFILES because the second command wipes out any effect of the first command.

You can do all of that in a single line.

If the archive you want to create is always going to be "AFN.zip" then use this:

Copy FILE=* CREATEFOLDER="AFN" ADDTOARCHIVE=.zip,nosplit,nofullpaths FILTER="DSL_Bundle" HERE

(You do not need to select anything at all before running it.)

If you want the archive to be named after a particular file, select that file and then use this:

@nofilenamequoting dopusrt /cmd Copy FILE=* CREATEFOLDER="{file$|noext}" ADDTOARCHIVE=.zip,nosplit,nofullpaths FILTER="DSL_Bundle" HERE

(The dopusrt /cmd at the start is a kludge to force the {file$|noext} to be turned into a filename before the Add to Archive window appears. Without it, you get a prompt that literally has {file$|noext} in it.)

Leo, thanks again.
It is difficult to explain in this format but I will try to be clear. Using Sort, followed by Select FIRST, followed by Select ALLFILES results in all files selected and the first file in the selection having a little white box around it. If I just use Select ALLFILES the last file selected before the command is executed will have the little white box around it. When more than one file is selected, the COPY ARCHIVE will name the archive file the one with the little white box. (in my testing).

I have been able to produce a working solution using WZZIP. I would appreciate any suggestions to improve.

Set SORTBY=name SORTREVERSE=Off
Select DSL_Bundle FILTER FILTERFLAGS=hidenomatch Type=Files
Select ^(\d{12}.C)(.*)(doc$|docx$) REGEXP
@firstfileonly
@set afn={filepath|ext=zzz}
Select ALLFILES
@sync:C:\Program Files\WinZip\WZZIP.EXE -spassword -ycAES256 {$afn} {F!}

Why have you switched to using WinZip? Did my suggestions not work?

I only tried the second suggestion and it does bring up the Archive Dialog box with the correct file name populated and with nosplit correctly set. Thank you.
I switched to winzip because my objective was to have a single button to click that would create (using the file name of a selected file) an encrypted zip file and include all the files matching a pattern in it.

Thanks,
Bob

Fair enough!

If the WinRar button you have is working then job done. :slight_smile:

Hi, I have a few questions related to the above...

  • I would like to add selected files to an archive, WITHOUT any dialog box coming up. ie. quietly in the background (maybe using the default archive settings specified in preferences). Can i confirm if this is currently possible?

  • I notice the rar and 7zip plugins do not have an option for splitting the archive. Will this be implemented at any point in the future? At least for one of the formats?

I ask because Dopus already has almost all the functionality I need, regarding archives, except for the few important details already mentioned. And for obvious reasons, I would much prefer to use the inbuilt capability.

I would like to be able to 1) encrypt filenames AND 2) split the archive, and 3) automate the process. Currently .7zip and .rar both allow 1) but 2) only works with .zip

So practically speaking my feature request would be:

  • a usedefaultsettings argument for using the settings specified under preferences \ archive plugins
  • a QUIET argument for silent archiving
  • a password: argument for inputting password
  • ability to split either .7zip or .rar

Any or all of these features would be greatly appreciated!

Use the ARCHIVE argument instead of ADDTOARCHIVE.

"Copy ARCHIVE" doesn't display the dialog while "Copy ADDTOARCHIVE" does.

For example, to create a 7z archive in the current folder without any prompts:

Copy ARCHIVE=.7z HERE

(For Zip files only, there's a bit more to it: Preferences / Zip & Other Archives / Zip Files / Ask for encryption/compression settings when copying into Zip files can force the dialog to be shown every time, but that shouldn't affect 7z and RAR even if it is on.)

However, if you want to create an archive with encrypted filenames then you'll need to provide a password to encrypt them, so you can't really avoid the prompt in that case.

Possibly. Support for creating split 7z and RAR archive is on the to-do list but isn't a high priority, to be honest. We'll probably support it eventually, just for completeness, but using 7-Zip or WinRAR's context menus to create split archives seems okay to me.

(Esp. given that WinRAR has to be installed to be able to create/modify RAR archives at all, and how rare it seems to create split 7z archives. FWIW, you can create a normal 7z archive and then split it manually via Tools->Split Files, since split 7z archives are literally just the original archive split into parts, with no additional headers. That won't work with RAR, though.)

1 Like

Hi, Thanks for the detailed clarifications

I tried using your suggestion to create a multi-7z archive...

@set name={dlgstringS|Name|{file$|noext}}
CreateFolder {$name}
Copy HERE ARCHIVE=.7z CREATEFOLDER={$name}
Split {$name}.7z SIZE 1MB TO "{sourcepath}{$name)"

...except the split parts do not get put into the named subfolder as I wanted.

P.S I'm inclined to use winrar exclusively, only because I would like to have a pre-configured password and automatic encrypted multi-archive creation. Having found
[url]WinRAR Compress/Decompress Buttons (and other)]

Still deciding though

Try this:

@nofilenamequoting @set name={dlgstringS|Name|{file$|noext}} Copy HERE ARCHIVE=.7z CREATEFOLDER="{$name}" CreateFolder "{$name}" READAUTO=no Split "{$name}.7z" SIZE 1MB TO "{sourcepath}{$name}"

Note that there was a ) in your original code that should be a }, which is easy to miss. I also changed some of the quoting and some other stuff. That seems to work for me, from a quick test.

Glad the main error was a )
I can use this template to construct other functions. Always learning...