ZIP compression level ignored

(Edit: This should no longer be needed with Opus 13.)

Using "single" currently switches Opus into using a non-batch mode, where the archive is opened and closed for each file that is added, making it a lot slower if there are a lot of files to add to each archive. (There's no reason you should have known this, it's just a quirk of how things are implemented on our side.)

Here's a script-button which does basically the same thing, and should work better. As a bonus, since it's a script it can be modified if you need more flexibility than "archive=single" provided.

As another bonus, the script also works with non-Zip formats, while I don't think "ARCHIVE=single" currently does.

The only really noteworthy thing about the script is that if a folder is selected and is empty, then it creates an empty archive rather than trying to create an archive from the folder (which would produce an unwanted "No work to do" error.)

(How to add buttons from this forum to your toolbars, Button .dcf Files section, for anyone who needs help with how to add the code below to a toolbar.)

Zip Single.dcf (2.5 KB)

Script code that is inside the .dcf file, just for reference:

function OnClick(clickData)
{
	var source = clickData.func.sourcetab;
	var cmd    = clickData.func.command;
	var work   = false;
	cmd.deselect = false; // Leave source files selected.
	cmd.ClearFiles();

	for (var e = new Enumerator(source.selected); !e.atEnd(); e.moveNext())
	{
		var f = e.item();

		if (IsEmptyDir(f))
		{
			var arcName = f.Path + "\\" + f.name_stem_m + ".zip";
			if (!DOpus.FSUtil.Exists(arcName))
			{
				work = true;
				cmd.AddLine("CreateFolder NAME=\"" + arcName + "\" ARCHIVE=.ZIP READAUTO=no NOUPDATESETTINGS");
			}
		}
		else
		{
			work = true;
			cmd.AddLine("Copy FILE=\"" + f.RealPath + "\" TO=\"" + f.Path + "\" ARCHIVE=.ZIP CREATEFOLDER=\"" + f.name_stem_m + ".zip\"");
		}
	}

	if (work)
	{
		cmd.Run();
	}
}

function IsEmptyDir(item)
{
	if (!item.is_dir)
	{
		return false;
	}

	var fe = DOpus.FSUtil.ReadDir(item.RealPath);

	return fe.complete;	
}
1 Like