Copy into multiple selected destinations

Overview:

This script-button copies the selection from the source side in to each selected folder on the destination side.

Before clicking the button:

After clicking the button:

Download:

If you download button in .dcf format, you can drag & drop it straight to your toolbars. See near the end of How to add buttons from this forum to your toolbars.

Script code:

Here is the script code, to help those using the forum to find scripting techniques. You do not need to use or understand any of this if you just wish to use the button.

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

	if (typeof dest != "object"
	||	dest.selected_dirs.count == 0
	||	source.selected.count == 0)
	{
		clickData.func.dlg.Request("Need selections on both sides.","OK");
		return;
	}

	for (var e = new Enumerator(dest.selected_dirs); !e.atEnd(); e.moveNext())
	{
		cmd.AddLine("Copy TO=\"" + e.item().RealPath + "\"");
	}

	cmd.Run();
}
4 Likes

I don't seem to understand how to add my path to the button, Can anyone explain what is the correct format for it ?

The button/script will copy the files you select on the source side into each of the folders you select on the destination side.

If you want to copy things to a fixed path, there's a much easier way to do that. Assuming that's what you want, what are the path(s) you want to copy things to?

Yes you are correct, Im looking for an option to copy into fixed path

LIke this one C:\Users\vvovk\OneDrive - Teichert\Desktop\Working On

Is there any classes or tutorial for creating buttons or scripting them

The command would be:

Copy TO "C:\Users\vvovk\OneDrive - Teichert\Desktop\Working On"

See here for how to use it: How to use buttons and scripts from this forum

2 Likes

Thank you very match!

Could this be used to insert a file into multiple zip archives?

Yes, if you replace selected_dirs with selected.

1 Like