Copy Selected items to .rar file Separately

I wants to copy Selected files & folders to .rar file Separetely in Current folder

I tried some way But I have failed. This code also doesn't work for me

Copy ARCHIVE=single FileType NEW=.rar CREATEFOLDER="{file$|noext}" HERE 

example: E:\test
in test folder I have some file & folders.
I select multiple file & folders like
file aa.txt
file bb.mp3
file cc.mp4
Folder One
Folder Tow
Now I want to a single click on this button
the button make 5 separate .rar file
file aa.rar
file bb.rar
file cc.rar
Folder One.rar
Folder Tow.rar

The Copy command does not have FileType or NEW arguments so your command would not work. (You can't insert different, unrelated commands into the arguments for a command; it won't understand them.)

For zip, Copy ARCHIVE=single HERE would be enough (although slow). For other archive formats, as well as zip with maximum speed, use this script, modifying any .zip in it to the format you want:

1 Like

Thank you so much Dear Leo. I just edit your script with the word rar for zip, it works fine for me. If any one need this, you can use this button.

Rar 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 + ".rar";
			if (!DOpus.FSUtil.Exists(arcName))
			{
				work = true;
				cmd.AddLine("CreateFolder NAME=\"" + arcName + "\" ARCHIVE=.rar READAUTO=no NOUPDATESETTINGS");
			}
		}
		else
		{
			work = true;
			cmd.AddLine("Copy FILE=\"" + f.RealPath + "\" TO=\"" + f.Path + "\" ARCHIVE=.rar CREATEFOLDER=\"" + f.name_stem_m + ".rar\"");
		}
	}

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

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

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

	return fe.complete;	
}